From 60c9392b6419efc4537650b406bd2d33b20fcfc7 Mon Sep 17 00:00:00 2001 From: ShaRose Date: Thu, 16 Jun 2022 23:38:36 -0230 Subject: 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. --- setup-user.in | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'setup-user.in') 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 -- cgit v1.2.3