diff --git a/add_user.sh b/add_user.sh index 790f86c..51f0ae4 100755 --- a/add_user.sh +++ b/add_user.sh @@ -7,18 +7,22 @@ set -e LOGIN="$1" [ -z "$LOGIN" ] && { echo "Użycie: $0 "; exit 1; } -setup_user() { +STEP=$2 + +add_user() { adduser -D -s /bin/sh -h "/home/$LOGIN" -H "$LOGIN" - addgroup "$LOGIN" tildeusers - PASS="$(openssl rand -base64 16 | sed 's/[\/\+\=\\]//g')" echo "$LOGIN":"$PASS" | chpasswd zfs create -o mountpoint="/home/$LOGIN" -o quota=200M "tank/ROOT/homes/$LOGIN" chown "$LOGIN":"$LOGIN" "/home/$LOGIN" +} + +setup_user() { + addgroup "$LOGIN" tildeusers # neomutt had issues with default vi - cat "export EDITOR=nvim" >> "/home/$LOGIN/.ashrc" + echo "export EDITOR=nvim" >> "/home/$LOGIN/.ashrc" # set cgroup CG_ROOT=/sys/fs/cgroup/users @@ -124,18 +128,24 @@ Twoje dane do Nextcloud to (https://cloud.tylda.org) to: EOF } -# critical path -setup_user -setup_nextcloud -send_welcome_mail - -# less important stuff -# shouldn't impact user obtaining registration email -setup_neomutt -setup_tmux -setup_gemini -setup_html -setup_weechat +if [ -z "$STEP" ]; then + # critical path + add_user + setup_user + setup_nextcloud + send_welcome_mail + + # less important stuff + # shouldn't impact user obtaining registration email + setup_neomutt + setup_tmux + setup_gemini + setup_html + setup_weechat +else + # use $STEP as fn to call + $STEP +fi chown -R "$LOGIN":"$LOGIN" "/home/$LOGIN/"