samba.sh/README.md add options requested in #38 and #39

This commit is contained in:
David Personette 2016-12-11 17:12:11 -05:00
parent b1e4baaa1d
commit b080e5c373
2 changed files with 15 additions and 7 deletions

View File

@ -36,7 +36,7 @@ OR set local storage:
required arg: "<path>" - full file path in container required arg: "<path>" - full file path in container
-n Start the 'nmbd' daemon to advertise the shares -n Start the 'nmbd' daemon to advertise the shares
-p Set ownership and permissions on the shares -p Set ownership and permissions on the shares
-s "<name;/path>[;browsable;readonly;guest;users;admins]" Configure a share -s "<name;/path>[;browse;readonly;guest;users;admins;wl]" Config a share
required arg: "<name>;<comment>;</path>" required arg: "<name>;<comment>;</path>"
<name> is how it's called for clients <name> is how it's called for clients
<path> path to share <path> path to share
@ -46,13 +46,15 @@ OR set local storage:
[guest] allowed default:'yes' or 'no' [guest] allowed default:'yes' or 'no'
[users] allowed default:'all' or list of allowed users [users] allowed default:'all' or list of allowed users
[admins] allowed default:'none' or list of admin users [admins] allowed default:'none' or list of admin users
[writelist] list of users that can write to a RO share
-t "" Configure timezone -t "" Configure timezone
possible arg: "[timezone]" - zoneinfo timezone for container possible arg: "[timezone]" - zoneinfo timezone for container
-u "<username;password>" Add a user -u "<username;password>[;ID;group]" Add a user
required arg: "<username>;<passwd>" required arg: "<username>;<passwd>"
<username> for user <username> for user
<password> for user <password> for user
[ID] for user [ID] for user
[group] for user
-w "<workgroup>" Configure the workgroup (domain) samba should use -w "<workgroup>" Configure the workgroup (domain) samba should use
required arg: "<workgroup>" required arg: "<workgroup>"
<workgroup> for samba <workgroup> for samba

View File

@ -65,10 +65,11 @@ perms() { local i file=/etc/samba/smb.conf
# guest) 'yes' or 'no' # guest) 'yes' or 'no'
# users) list of allowed users # users) list of allowed users
# admins) list of admin users # admins) list of admin users
# writelist) list of users that can write to a RO share
# Return: result # Return: result
share() { local share="$1" path="$2" browsable=${3:-yes} ro=${4:-yes} \ share() { local share="$1" path="$2" browsable=${3:-yes} ro=${4:-yes} \
guest=${5:-yes} users=${6:-""} admins=${7:-""} \ guest=${5:-yes} users=${6:-""} admins=${7:-""} \
file=/etc/samba/smb.conf writelist=${8:-""} file=/etc/samba/smb.conf
sed -i "/\\[$share\\]/,/^\$/d" $file sed -i "/\\[$share\\]/,/^\$/d" $file
echo "[$share]" >>$file echo "[$share]" >>$file
echo " path = $path" >>$file echo " path = $path" >>$file
@ -79,6 +80,8 @@ share() { local share="$1" path="$2" browsable=${3:-yes} ro=${4:-yes} \
echo " valid users = $(tr ',' ' ' <<< $users)" >>$file echo " valid users = $(tr ',' ' ' <<< $users)" >>$file
[[ ${admins:-""} && ! ${admins:-""} =~ none ]] && [[ ${admins:-""} && ! ${admins:-""} =~ none ]] &&
echo " admin users = $(tr ',' ' ' <<< $admins)" >>$file echo " admin users = $(tr ',' ' ' <<< $admins)" >>$file
[[ ${writelist:-""} && ! ${writelist:-""} =~ none ]] &&
echo " write list = $(tr ',' ' ' <<< $writelist)" >>$file
echo "" >>$file echo "" >>$file
} }
@ -105,8 +108,9 @@ timezone() { local timezone="${1:-EST5EDT}"
# password) for user # password) for user
# id) for user # id) for user
# Return: user added to container # Return: user added to container
user() { local name="${1}" passwd="${2}" id="${3:-""}" user() { local name="${1}" passwd="${2}" id="${3:-""}" group="${4:-""}"
useradd "$name" -M ${id:+-u $id} grep -q "^$group:" /etc/group || groupadd "$group"
useradd "$name" -M ${id:+-u $id} ${group:+-g $group}
echo -e "$passwd\n$passwd" | smbpasswd -s -a "$name" echo -e "$passwd\n$passwd" | smbpasswd -s -a "$name"
} }
@ -132,7 +136,7 @@ Options (fields in '[]' are optional, '<>' are required):
required arg: \"<path>\" - full file path in container required arg: \"<path>\" - full file path in container
-n Start the 'nmbd' daemon to advertise the shares -n Start the 'nmbd' daemon to advertise the shares
-p Set ownership and permissions on the shares -p Set ownership and permissions on the shares
-s \"<name;/path>[;browsable;readonly;guest;users;admins]\" Configure a share -s \"<name;/path>[;browse;readonly;guest;users;admins;wl]\" Config a share
required arg: \"<name>;<comment>;</path>\" required arg: \"<name>;<comment>;</path>\"
<name> is how it's called for clients <name> is how it's called for clients
<path> path to share <path> path to share
@ -142,13 +146,15 @@ Options (fields in '[]' are optional, '<>' are required):
[guest] allowed default:'yes' or 'no' [guest] allowed default:'yes' or 'no'
[users] allowed default:'all' or list of allowed users [users] allowed default:'all' or list of allowed users
[admins] allowed default:'none' or list of admin users [admins] allowed default:'none' or list of admin users
[writelist] list of users that can write to a RO share
-t \"\" Configure timezone -t \"\" Configure timezone
possible arg: \"[timezone]\" - zoneinfo timezone for container possible arg: \"[timezone]\" - zoneinfo timezone for container
-u \"<username;password>\" Add a user -u \"<username;password>[;ID;group]\" Add a user
required arg: \"<username>;<passwd>\" required arg: \"<username>;<passwd>\"
<username> for user <username> for user
<password> for user <password> for user
[ID] for user [ID] for user
[group] for user
-w \"<workgroup>\" Configure the workgroup (domain) samba should use -w \"<workgroup>\" Configure the workgroup (domain) samba should use
required arg: \"<workgroup>\" required arg: \"<workgroup>\"
<workgroup> for samba <workgroup> for samba