summaryrefslogtreecommitdiff
path: root/setup-user.in
diff options
context:
space:
mode:
authorShaRose <ShawnAndrewRose@Gmail.Com>2022-06-16 23:38:36 -0230
committerNatanael Copa <ncopa@alpinelinux.org>2022-06-28 16:14:51 +0000
commit60c9392b6419efc4537650b406bd2d33b20fcfc7 (patch)
tree19c05eda36a43f9b1c6f98811c67f891c66ebf14 /setup-user.in
parentf0f7381d2253d06777d209e2c97150a0b40c9ffe (diff)
downloadalpine-conf-60c9392b6419efc4537650b406bd2d33b20fcfc7.zip
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.
Diffstat (limited to 'setup-user.in')
-rw-r--r--setup-user.in10
1 files changed, 8 insertions, 2 deletions
diff --git a/setup-user.in b/setup-user.in
index a94b533..88f28b4 100644
--- a/setup-user.in
+++ b/setup-user.in
@@ -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