separate adding user from setting it up
also, echo instead of cat
This commit is contained in:
40
add_user.sh
40
add_user.sh
@@ -7,18 +7,22 @@ set -e
|
||||
LOGIN="$1"
|
||||
[ -z "$LOGIN" ] && { echo "Użycie: $0 <login>"; exit 1; }
|
||||
|
||||
setup_user() {
|
||||
adduser -D -s /bin/sh -h "/home/$LOGIN" -H "$LOGIN"
|
||||
addgroup "$LOGIN" tildeusers
|
||||
STEP=$2
|
||||
|
||||
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"
|
||||
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
|
||||
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
|
||||
# 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/"
|
||||
|
||||
|
||||
Reference in New Issue
Block a user