From fea182b887970b0ec90aefd305888517832044c4 Mon Sep 17 00:00:00 2001 From: Paul Krizak Date: Sun, 6 Nov 2016 20:01:27 -0800 Subject: [PATCH 1/2] Ability to add groups, and users to those groups --- samba.sh | 25 ++++++++++++++++++++----- 1 file changed, 20 insertions(+), 5 deletions(-) diff --git a/samba.sh b/samba.sh index e809606..db4845b 100755 --- a/samba.sh +++ b/samba.sh @@ -96,14 +96,23 @@ timezone() { local timezone="${1:-EST5EDT}" fi } +### group: add a group +# Arguments: +# name) for group +# gid) for group +# Return: group added to container +group() { local name="${1}" id="${2:-""}" + groupadd ${id:+-g $id} "$name" +} + ### user: add a user # Arguments: # name) for user # password) for user # id) for user # Return: user added to container -user() { local name="${1}" passwd="${2}" id="${3:-""}" - useradd "$name" -M ${id:+-u $id} +user() { local name="${1}" passwd="${2}" id="${3:-""}" groups="${4:-""}" + useradd "$name" -M ${id:+-u $id} ${groups:+-G $groups} echo -e "$passwd\n$passwd" | smbpasswd -s -a "$name" } @@ -141,11 +150,16 @@ Options (fields in '[]' are optional, '<>' are required): users' homedirs at /home -t \"\" Configure timezone possible arg: \"[timezone]\" - zoneinfo timezone for container - -u \"\" Add a user + -g \"[;gid]\" Add a group + required arg: \"\" + name of group + [gid] set a specific GID + -u \"[;id;group,group]\" Add a user required arg: \";\" for user for user - [ID] for user + [id] UID for user + [group,group] supplementary groups for user -w \"\" Configure the workgroup (domain) samba should use required arg: \"\" for samba @@ -155,7 +169,7 @@ The 'command' (if provided and valid) will be run instead of samba exit $RC } -while getopts ":hi:nps:mt:u:w:" opt; do +while getopts ":hi:npls:mt:g:u:w:" opt; do case "$opt" in h) usage ;; i) import "$OPTARG" ;; @@ -164,6 +178,7 @@ while getopts ":hi:nps:mt:u:w:" opt; do s) eval share $(sed 's/^\|$/"/g; s/;/" "/g' <<< $OPTARG) ;; m) homes ;; t) timezone "$OPTARG" ;; + g) eval group $(sed 's|;| |g' <<< $OPTARG) ;; u) eval user $(sed 's|;| |g' <<< $OPTARG) ;; w) workgroup "$OPTARG" ;; "?") echo "Unknown option: -$OPTARG"; usage 1 ;; From 1a0be89885dc7f94960a784769d669b7ac629e40 Mon Sep 17 00:00:00 2001 From: Paul Krizak Date: Sun, 6 Nov 2016 20:03:43 -0800 Subject: [PATCH 2/2] Remove symlnk option from another branch --- samba.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/samba.sh b/samba.sh index db4845b..c493a1f 100755 --- a/samba.sh +++ b/samba.sh @@ -169,7 +169,7 @@ The 'command' (if provided and valid) will be run instead of samba exit $RC } -while getopts ":hi:npls:mt:g:u:w:" opt; do +while getopts ":hi:nps:mt:g:u:w:" opt; do case "$opt" in h) usage ;; i) import "$OPTARG" ;;