mirror of
https://github.com/atmoz/sftp.git
synced 2024-11-17 12:51:33 -05:00
Tidy up variables in createUser()
This commit is contained in:
parent
4edb2a932e
commit
9405974cc9
1 changed files with 8 additions and 9 deletions
17
entrypoint
17
entrypoint
|
@ -37,29 +37,28 @@ function createUser() {
|
||||||
log "Parsing user data: \"$@\""
|
log "Parsing user data: \"$@\""
|
||||||
|
|
||||||
IFS=':' read -a args <<< $@
|
IFS=':' read -a args <<< $@
|
||||||
index=0
|
|
||||||
|
skipIndex=0
|
||||||
|
chpasswdOptions=""
|
||||||
|
useraddOptions="--no-user-group"
|
||||||
|
|
||||||
user="${args[0]}"; validateArg "username" "$user" "$reUser" || return 1
|
user="${args[0]}"; validateArg "username" "$user" "$reUser" || return 1
|
||||||
pass="${args[1]}"; validateArg "password" "$pass" "$rePass" || return 1
|
pass="${args[1]}"; validateArg "password" "$pass" "$rePass" || return 1
|
||||||
|
|
||||||
if [ "${args[2]}" == "e" ]; then
|
if [ "${args[2]}" == "e" ]; then
|
||||||
chpasswdOptions="-e"
|
chpasswdOptions="-e"
|
||||||
index=1
|
skipIndex=1
|
||||||
else
|
|
||||||
chpasswdOptions=""
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
uid="${args[$[$index+2]]}"; validateArg "UID" "$uid" "$reUid" || return 1
|
uid="${args[$[$skipIndex+2]]}"; validateArg "UID" "$uid" "$reUid" || return 1
|
||||||
gid="${args[$[$index+3]]}"; validateArg "GID" "$gid" "$reGid" || return 1
|
gid="${args[$[$skipIndex+3]]}"; validateArg "GID" "$gid" "$reGid" || return 1
|
||||||
dir="${args[$[$index+4]]}"; validateArg "dirs" "$dir" "$reDir" || return 1
|
dir="${args[$[$skipIndex+4]]}"; validateArg "dirs" "$dir" "$reDir" || return 1
|
||||||
|
|
||||||
if getent passwd $user > /dev/null; then
|
if getent passwd $user > /dev/null; then
|
||||||
log "WARNING: User \"$user\" already exists. Skipping."
|
log "WARNING: User \"$user\" already exists. Skipping."
|
||||||
return 0
|
return 0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
useraddOptions="--no-user-group"
|
|
||||||
|
|
||||||
if [ -n "$uid" ]; then
|
if [ -n "$uid" ]; then
|
||||||
useraddOptions="$useraddOptions --non-unique --uid $uid"
|
useraddOptions="$useraddOptions --non-unique --uid $uid"
|
||||||
fi
|
fi
|
||||||
|
|
Loading…
Reference in a new issue