July 18, 201015 yr Currently running 4.5.6 Here's what I have in anonymous.sh: #!/bin/bash # # Title: setup_anon_shares.sh # # Summary: # Use this script to enable anonymous access to pre-configured SMB shares. The script will # enable the guest account in your samba configuration and update smb.shares to allow # guest access to the specified share names. # # DISCLAIMER: # Your use of this script is at your sole risk. This script is provided # "as -is", without any warranty # # Further, the authors of this script shall not be liable for any damages # you may sustain by using this information, whether direct, indirect, # special, incidental or consequential, even if they have been advised of # the possibility of such damages. # Shares you wish to allow anonymous access on. Share names must be separated by the | character, # for example, "Video|Music" would allow anonymous access to the Video and Music shares. ver=1.1 progname=`basename $0` function usage { echo "Usage: $0 [ -s sharenames ] -v" echo " -s = supply share list for anonymous access" echo " -v = print program version" echo "example: $progname -s \"Movies|Music\"" echo "" echo "if you do not supply a share list, then it will default to \"Movies|TV\"" echo "The share list must be enclosed in quote marks as in the above example." } sAnonShares="movies|tv series|dvd" while getopts ":hv" opt; do case $opt in s ) sAnonShares=$OPTARG ;; h ) usage >&2 ;; v ) echo $progname version: $ver; exit 0 ;; \?) usage >&2 ;; esac done shift $(($OPTIND - 1)) if [ $# != 0 ] then usage >&2 exit 2 fi # Configure samba guest access. The "guest" account will be the nobody account which should already exist. # What we're doing is telling samba to map invalid user accounts to the guest user. # newer versions of unRAID use different named files for SAMBA. # set the names to be used based on the existance of the newly named file. if [ -f /etc/samba/smb-shares.conf ] then sambaShares="/etc/samba/smb-shares.conf" sambaNames="/etc/samba/smb-names.conf" else sambaShares="/etc/samba/smb.shares" sambaNames="/etc/samba/smb.names" fi # Ensure that the entries aren't duplicated function configureSmbNames { egrep "^[[:space:]]*$1[[:space:]]*$" $sambaNames >/dev/null 2>&1 if [ $? != 0 ] then echo $1 >> $sambaNames echo "Adding " $1 " to " $sambaNames 1>&2 fi } configureSmbNames "guest account = nobody" configureSmbNames "map to guest = bad user" # Awk script that will insert "guest ok = yes" into the specified share configurations. # The script will ensure that the value is not duplicated. awk -vshares="$sAnonShares" ' BEGIN { found = 0 split(shares,shareArray,"|") } # original pattern did not work with share with spaces, dashes, or underscores in the name #/^[[:space:]]*\[[[:alnum:][:space:]]+\][[:space:]]*$/ { # this pattern looks for "[" share name "]" and works with share names with characters other than alpha. /^[[:space:]]*\[.*][[:space:]]*$/ { # We have reached the line defining a new share. If we have not yet writen the # guest ok for the prior "found" share, print it now. for (i in shareArray) { if ( shareArray[i] == currentShare && found == 0 ) { print "\tguest ok = yes"; print "Adding \"guest ok\" to " currentShare > "/dev/stderr" break; } } found = 0; currentShare = $0; # delete the brakets gsub(/[\[\]]/, "", currentShare); } # If we find a line for "guest ok" set the flag so we do not add another $0 ~ /^[[:space:]]*guest[[:space:]]*ok[[:space:]]*=[[:space:]]*yes[[:space:]]*$/ { found = 1; } # Anything non-blank lines print to the new file. $0 !~ /^[[:space:]]*$/ { print } END { for (i in shareArray) { if ( shareArray[i] == currentShare && found == 0 ) { print "\tguest ok = yes"; print "Adding \"guest ok\" to " currentShare > "/dev/stderr" break; } } } ' $sambaShares > /tmp/smb.shares # Rename the temp file and reload samba cat /tmp/smb.shares > $sambaShares rm -f /tmp/smb.shares smbcontrol smbd reload-config Here's the last line in the go script: sleep 10; /boot/anonymous.sh -s "movies|dvd|tv series" I cannot get it to work. It used to work but now it no longer works for some reasons. For example, with unraid off, I would turn on my PC. Then I'd turn on unraid. When unraid is done booting up, and I click on tower...windows would prompt me asking for password. Same goes for the other way round where I'd turn unraid on first, then turn my PC on. I also tried manually running /boot/anonymous.sh via telnet and it doesn't work as well. The shared folders are set to Export read-only. What could be the problem? EDIT: btw, when windows ask for login credential, and I manually enter "guest", without password. It would login.
July 18, 201015 yr Author anybody? Nevermind, problem fixed: configureSmbNames "map to guest = bad password"
Archived
This topic is now archived and is closed to further replies.