samba.sh README.md add option to set ownership and permissions for configured shares

This commit is contained in:
David Personette 2016-06-08 07:36:20 -04:00
parent 176770244b
commit 9216111a46
2 changed files with 17 additions and 1 deletions

View File

@ -33,6 +33,7 @@ OR set local storage:
-i "<path>" Import smbpassword -i "<path>" Import smbpassword
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
-s "<name;/path>[;browsable;readonly;guest;users]" Configure a share -s "<name;/path>[;browsable;readonly;guest;users]" Configure 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

View File

@ -29,6 +29,18 @@ import() { local name id file="${1}"
pdbedit -i smbpasswd:$file pdbedit -i smbpasswd:$file
} }
### perms: fix ownership and permissions of share paths
# Arguments:
# none)
# Return: result
perms() { local i file=/etc/samba/smb.conf
for i in $(awk -F ' = ' '/ path = / {print $2}'); do
chown -Rh smbuser. $i
find $i -type d -exec chmod 775 {} \;
find $i -type f -exec chmod 664 {} \;
done
}
### share: Add share ### share: Add share
# Arguments: # Arguments:
# share) share name # share) share name
@ -101,6 +113,7 @@ Options (fields in '[]' are optional, '<>' are required):
-i \"<path>\" Import smbpassword -i \"<path>\" Import smbpassword
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
-s \"<name;/path>[;browsable;readonly;guest;users]\" Configure a share -s \"<name;/path>[;browsable;readonly;guest;users]\" Configure 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
@ -126,11 +139,12 @@ The 'command' (if provided and valid) will be run instead of samba
exit $RC exit $RC
} }
while getopts ":hi:ns:t:u:w:" opt; do while getopts ":hi:nps:t:u:w:" opt; do
case "$opt" in case "$opt" in
h) usage ;; h) usage ;;
i) import "$OPTARG" ;; i) import "$OPTARG" ;;
n) NMBD="true" ;; n) NMBD="true" ;;
p) PERMISSIONS="true" ;;
s) eval share $(sed 's/^\|$/"/g; s/;/" "/g' <<< $OPTARG) ;; s) eval share $(sed 's/^\|$/"/g; s/;/" "/g' <<< $OPTARG) ;;
t) timezone "$OPTARG" ;; t) timezone "$OPTARG" ;;
u) eval user $(sed 's|;| |g' <<< $OPTARG) ;; u) eval user $(sed 's|;| |g' <<< $OPTARG) ;;
@ -143,6 +157,7 @@ shift $(( OPTIND - 1 ))
[[ "${TZ:-""}" ]] && timezone "$TZ" [[ "${TZ:-""}" ]] && timezone "$TZ"
[[ "${WORKGROUP:-""}" ]] && workgroup "$WORKGROUP" [[ "${WORKGROUP:-""}" ]] && workgroup "$WORKGROUP"
[[ "${PERMISSIONS:-""}" ]] && perms
if [[ $# -ge 1 && -x $(which $1 2>&-) ]]; then if [[ $# -ge 1 && -x $(which $1 2>&-) ]]; then
exec "$@" exec "$@"