Commit 60c9392b authored by ShaRose's avatar ShaRose Committed by Natanael Copa
Browse files

Add -u unlock command to setup-user

Copied from github PR, but add -u so that you can include to forcably unlock the user after creation.

Useful for when you want to create a user automatically so they can log in using a passed SSH key (-k), but without a password so they can set up a password after connecting.
parent f0f7381d
Pipeline #126472 passed with stage
in 24 seconds
......@@ -6,7 +6,7 @@ PREFIX=@PREFIX@
usage() {
cat <<-__EOF__
usage: setup-user [-h] [-f FULLNAME] [-g GROUPS] [-k SSHKEY] [USERNAME]
usage: setup-user [-h] [-a] [-u] [-f FULLNAME] [-g GROUPS] [-k SSHKEY] [USERNAME]
Create user account
......@@ -17,19 +17,22 @@ usage() {
-g Comma or space separated list of groups to add user to
-k ssh key or URL to ssh key (eg. https://gitlab.alpinelinux.org/user.keys)
or 'none' for no key
-u Unlock the user automatically (eg. creating the user non-interactively
with an ssh key for login)
If USERNAME is not specified user will be prompted.
__EOF__
exit $1
}
while getopts "af:g:hk:" opt; do
while getopts "af:g:hk:u" opt; do
case $opt in
a) admin=1;;
h) usage 0;;
f) fullnameopt="$OPTARG";;
g) groups="$OPTARG";;
k) keysopt="$OPTARG";;
u) forceunlock=1;;
'?') usage "1" >&2;;
esac
done
......@@ -140,3 +143,6 @@ if [ -n "$admin" ]; then
$MOCK addgroup "$username" "wheel" || exit
fi
if [ -n "$forceunlock" ]; then
$MOCK passwd -u "$username" 2> /dev/null
fi
\ No newline at end of file
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment