summaryrefslogtreecommitdiff
path: root/setup-user.in
diff options
context:
space:
mode:
authorNatanael Copa <ncopa@alpinelinux.org>2022-05-19 19:01:04 +0000
committerNatanael Copa <ncopa@alpinelinux.org>2022-05-19 19:26:54 +0000
commit2425a623a2437d21bbc176e9f72cd1523bc47486 (patch)
tree2b46f0f9b5082d0055bf99611e5fd3ba1f767021 /setup-user.in
parent9a6aa242d38e5c35ba258b371ce287f40e86572d (diff)
downloadalpine-conf-2425a623a2437d21bbc176e9f72cd1523bc47486.zip
setup-user: add -g option to specify groups
Diffstat (limited to 'setup-user.in')
-rw-r--r--setup-user.in12
1 files changed, 10 insertions, 2 deletions
diff --git a/setup-user.in b/setup-user.in
index c02c1a2..789ff84 100644
--- a/setup-user.in
+++ b/setup-user.in
@@ -6,13 +6,14 @@ PREFIX=@PREFIX@
usage() {
cat <<-__EOF__
- usage: setup-user [-h] [-f FULLNAME] [-k SSHKEY] [USERNAME]
+ usage: setup-user [-h] [-f FULLNAME] [-g GROUPS] [-k SSHKEY] [USERNAME]
Create user account
options:
-h Show this help
-f Set full name for user
+ -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
@@ -21,10 +22,11 @@ usage() {
exit $1
}
-while getopts "f:hk:" opt; do
+while getopts "f:g:hk:" opt; do
case $opt in
h) usage 0;;
f) fullname="$OPTARG";;
+ g) groups="$OPTARG";;
k) keysopt="$OPTARG";;
'?') usage "1" >&2;;
esac
@@ -98,3 +100,9 @@ if [ -n "$sshkeys" ] && [ "$sshkeys" != "none" ]; then
mkdir -p "$ROOT"/home/$username/.ssh
echo "$sshkeys" > "$ROOT"/home/$username/.ssh/authorized_keys
fi
+
+if [ -n "$groups" ] && [ "$groups" != "none" ]; then
+ for i in $(echo $groups | tr ',' ' '); do
+ $MOCK addgroup "$username" "$i" || exit
+ done
+fi