From 76e4eb751d86503a769dfc689f1bda22bd868284 Mon Sep 17 00:00:00 2001 From: smoorg Date: Mon, 13 Jul 2026 12:26:15 +0200 Subject: [PATCH 1/2] separate adding user from setting it up also, echo instead of cat --- add_user.sh | 42 ++++++++++++++++++++++++++---------------- 1 file changed, 26 insertions(+), 16 deletions(-) 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/" From 08983174b81360de1a088f8b41734c1b377bbca7 Mon Sep 17 00:00:00 2001 From: smoorg Date: Mon, 13 Jul 2026 12:26:52 +0200 Subject: [PATCH 2/2] make sure nextcloud gets its password --- add_user.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/add_user.sh b/add_user.sh index 51f0ae4..6e9d711 100755 --- a/add_user.sh +++ b/add_user.sh @@ -8,10 +8,10 @@ LOGIN="$1" [ -z "$LOGIN" ] && { echo "Użycie: $0 "; exit 1; } STEP=$2 +PASS="$(openssl rand -base64 16 | sed 's/[\/\+\=\\]//g')" add_user() { adduser -D -s /bin/sh -h "/home/$LOGIN" -H "$LOGIN" - 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"