samba.sh/README.md fix #190 to allow setting GID and fix USERID derp

This commit is contained in:
David Personette 2019-07-06 18:34:52 -04:00
parent 000ec99126
commit e14098dbbe
2 changed files with 10 additions and 5 deletions

View File

@ -53,12 +53,13 @@ OR set local storage:
[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 [writelist] list of users that can write to a RO share
[comment] description of share [comment] description of share
-u "<username;password>[;ID;group]" Add a user -u "<username;password>[;ID;group;GID]" 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 [group] for user
[GID] for group
-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

@ -135,9 +135,12 @@ smb() { local file=/etc/samba/smb.conf
# password) for user # password) for user
# id) for user # id) for user
# group) for user # group) for user
# gid) for group
# Return: user added to container # Return: user added to container
user() { local name="$1" passwd="$2" id="${3:-""}" group="${4:-""}" user() { local name="$1" passwd="$2" id="${3:-""}" group="${4:-""}" \
[[ "$group" ]] && { grep -q "^$group:" /etc/group || addgroup "$group"; } gid="${5:-""}"
[[ "$group" ]] && { grep -q "^$group:" /etc/group ||
addgroup ${gid:+--gid $gid }"$group"; }
grep -q "^$name:" /etc/passwd || grep -q "^$name:" /etc/passwd ||
adduser -D -H ${group:+-G $group} ${id:+-u $id} "$name" adduser -D -H ${group:+-G $group} ${id:+-u $id} "$name"
echo -e "$passwd\n$passwd" | smbpasswd -s -a "$name" echo -e "$passwd\n$passwd" | smbpasswd -s -a "$name"
@ -191,12 +194,13 @@ Options (fields in '[]' are optional, '<>' are required):
[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 [writelist] list of users that can write to a RO share
[comment] description of share [comment] description of share
-u \"<username;password>[;ID;group]\" Add a user -u \"<username;password>[;ID;group;GID]\" 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 [group] for user
[GID] for group
-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
@ -210,7 +214,7 @@ The 'command' (if provided and valid) will be run instead of samba
exit $RC exit $RC
} }
[[ "${USERID:-""}" =~ ^[0-9]+$ ]] && usermod -u $USERID -o smbuser [[ "${USERID:-""}" =~ ^[0-9]+$ ]] && usermod -u $USERID -o smbuser&&unset USERID
[[ "${GROUPID:-""}" =~ ^[0-9]+$ ]] && groupmod -g $GROUPID -o users [[ "${GROUPID:-""}" =~ ^[0-9]+$ ]] && groupmod -g $GROUPID -o users
while getopts ":hc:g:i:nprs:Su:Ww:I:" opt; do while getopts ":hc:g:i:nprs:Su:Ww:I:" opt; do