README.md and samba.sh add import option for smbpasswd
This commit is contained in:
parent
426fd586c6
commit
ab15aae77d
@ -27,10 +27,11 @@ OR set local storage:
|
||||
## Configuration
|
||||
|
||||
sudo docker run -it --rm dperson/samba -h
|
||||
|
||||
Usage: samba.sh [-opt] [command]
|
||||
Options (fields in '[]' are optional, '<>' are required):
|
||||
-h This help
|
||||
-i "<path>" Import smbpassword
|
||||
required arg: "<path>" - full file path in container to import
|
||||
-s "<name;/path>[;browse;readonly;guest;users]" Configure a share
|
||||
required arg: "<name>;<comment>;</path>"
|
||||
<name> is how it's called for clients
|
||||
|
17
samba.sh
17
samba.sh
@ -18,6 +18,17 @@
|
||||
|
||||
set -o nounset # Treat unset variables as an error
|
||||
|
||||
### import: import a smbpasswd file
|
||||
# Arguments:
|
||||
# file) file to import
|
||||
# Return: user(s) added to container
|
||||
import() { local name file="${2}"
|
||||
for name in $(cat $file | cut -d: -f1); do
|
||||
useradd "$name" -M
|
||||
done
|
||||
pdbedit -i smbpasswd:$file
|
||||
}
|
||||
|
||||
### share: Add share
|
||||
# Arguments:
|
||||
# share) share name
|
||||
@ -62,6 +73,7 @@ user() { local name="${1}" passwd="${2}"
|
||||
useradd "$name" -M
|
||||
echo "$passwd" | tee - | smbpasswd -s -a "$name"
|
||||
}
|
||||
|
||||
### usage: Help
|
||||
# Arguments:
|
||||
# none)
|
||||
@ -70,6 +82,8 @@ usage() { local RC=${1:-0}
|
||||
echo "Usage: ${0##*/} [-opt] [command]
|
||||
Options (fields in '[]' are optional, '<>' are required):
|
||||
-h This help
|
||||
-i \"<path>\" Import smbpassword
|
||||
required arg: \"<path>\" - full file path in container to import
|
||||
-s \"<name;/path>[;browse;readonly;guest;users]\" Configure a share
|
||||
required arg: \"<name>;<comment>;</path>\"
|
||||
<name> is how it's called for clients
|
||||
@ -90,9 +104,10 @@ The 'command' (if provided and valid) will be run instead of samba
|
||||
exit $RC
|
||||
}
|
||||
|
||||
while getopts ":ht:u:s:" opt; do
|
||||
while getopts ":hi:t:u:s:" opt; do
|
||||
case "$opt" in
|
||||
h) usage ;;
|
||||
i) import "$OPTARG" ;;
|
||||
s) eval share $(sed 's/^\|$/"/g; s/;/" "/g' <<< $OPTARG) ;;
|
||||
u) eval user $(sed 's/;/ /g' <<< $OPTARG) ;;
|
||||
t) timezone "$OPTARG" ;;
|
||||
|
Loading…
Reference in New Issue
Block a user