samba.sh / README.md fix #74 merge patch

This commit is contained in:
David Personette 2017-10-08 15:12:08 -04:00
parent 03c92bda3b
commit 99ea2cad8c
2 changed files with 18 additions and 1 deletions

View File

@ -32,6 +32,8 @@ OR set local storage:
-h This help -h This help
-c "<from:to>" setup character mapping for file/directory names -c "<from:to>" setup character mapping for file/directory names
required arg: "<from:to>" character mappings separated by ',' required arg: "<from:to>" character mappings separated by ','
-g "<parameter>" Provide global option for smb.conf
required arg: "<parameter>" - IE: -g "log level = 2"
-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

View File

@ -33,6 +33,18 @@ charmap() { local chars="$1" file=/etc/samba/smb.conf
sed -i '/catia:mappings/s/ =.*/ = '"$chars" $file sed -i '/catia:mappings/s/ =.*/ = '"$chars" $file
} }
### global: set a global config option
# Arguments:
# option) raw option
# Return: line added to smb.conf (replaces existing line with same key)
global() { local key="${1%%=*}" value="${1##*=}" file=/etc/samba/smb.conf
if grep -qE '^\s*'"$key" "$file"; then
sed -i 's|^\s*'"$key"'.*| '"$key = $value"'|' "$file"
else
sed -i '/\[global\]/a \ '"$key = $value" "$file"
fi
}
### import: import a smbpasswd file ### import: import a smbpasswd file
# Arguments: # Arguments:
# file) file to import # file) file to import
@ -162,6 +174,8 @@ Options (fields in '[]' are optional, '<>' are required):
-h This help -h This help
-c \"<from:to>\" setup character mapping for file/directory names -c \"<from:to>\" setup character mapping for file/directory names
required arg: \"<from:to>\" character mappings separated by ',' required arg: \"<from:to>\" character mappings separated by ','
-g \"<parameter>\" Provide global option for smb.conf
required arg: \"<parameter>\" - IE: -g \"log level = 2\"
-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
@ -200,10 +214,11 @@ The 'command' (if provided and valid) will be run instead of samba
[[ "${USERID:-""}" =~ ^[0-9]+$ ]] && usermod -u $USERID -o smbuser [[ "${USERID:-""}" =~ ^[0-9]+$ ]] && usermod -u $USERID -o smbuser
[[ "${GROUPID:-""}" =~ ^[0-9]+$ ]] && groupmod -g $GROUPID -o users [[ "${GROUPID:-""}" =~ ^[0-9]+$ ]] && groupmod -g $GROUPID -o users
while getopts ":hc:i:nprs:St:u:Ww:" opt; do while getopts ":hc:g:i:nprs:St:u:Ww:" opt; do
case "$opt" in case "$opt" in
h) usage ;; h) usage ;;
c) charmap "$OPTARG" ;; c) charmap "$OPTARG" ;;
g) global "$OPTARG" ;;
i) import "$OPTARG" ;; i) import "$OPTARG" ;;
n) NMBD="true" ;; n) NMBD="true" ;;
p) PERMISSIONS="true" ;; p) PERMISSIONS="true" ;;