move all steps to functions #7

Merged
v0id1st merged 6 commits from editor into main 2026-06-23 00:52:03 +02:00
Showing only changes of commit 0f53834083 - Show all commits

View File

@@ -7,17 +7,6 @@ set -e
LOGIN="$1"
[ -z "$LOGIN" ] && { echo "Użycie: $0 <login>"; exit 1; }
# 1. Użytkownik i hasło
PASS="$(openssl rand -base64 16 | sed 's/[\/\+\=\\]//g')"
adduser -D -s /bin/sh -h /home/$LOGIN -H "$LOGIN"
echo "$LOGIN:$PASS" | chpasswd
addgroup $LOGIN tildeusers
# 2. Dataset ZFS (quota 200MB)
zfs create -o mountpoint=/home/$LOGIN -o quota=200M tank/ROOT/homes/$LOGIN
chown $LOGIN:$LOGIN /home/$LOGIN
cat "export EDITOR=nvim" >> /home/$LOGIN/.ashrc
setup_neomutt () {
for dir in "Inbox" "Sent" "Drafts" "Trash"; do
for subdir in "cur" "new" "tmp"; do
@@ -29,15 +18,6 @@ setup_neomutt () {
chmod -R 0700 /home/"$LOGIN"/Maildir
}
cp -r /root/helpers/public_html /home/$LOGIN/
sed -i "s/<<USER>>/$LOGIN/g" /home/$LOGIN/public_html/index.php
sed -i "s/<<USER>>/$LOGIN/g" /home/$LOGIN/public_html/parts/header.php
sed -i "s/<<USER>>/$LOGIN/g" /home/$LOGIN/public_html/blog/index.php
mkdir -p /home/$LOGIN/.config/weechat/
cp /root/helpers/irc.conf /home/$LOGIN/.config/weechat
setup_tmux () {
mkdir -p /home/"$LOGIN"/.config/tmux
cat << EOF > /home/"$LOGIN"/.config/tmux/tmux.conf
@@ -70,10 +50,32 @@ setup_gemini () {
EOF
}
# 1. Użytkownik i hasło
PASS="$(openssl rand -base64 16 | sed 's/[\/\+\=\\]//g')"
adduser -D -s /bin/sh -h "/home/$LOGIN" -H "$LOGIN"
echo "$LOGIN:$PASS" | chpasswd
addgroup $LOGIN tildeusers
# 2. Dataset ZFS (quota 200MB)
zfs create -o mountpoint="/home/$LOGIN" -o quota=200M tank/ROOT/homes/$LOGIN
chown $LOGIN:$LOGIN /home/$LOGIN
cat "export EDITOR=nvim" >> "/home/$LOGIN/.ashrc"
setup_neomutt
setup_tmux
setup_gemini
cp -r /root/helpers/public_html "/home/$LOGIN/"
sed -i "s/<<USER>>/$LOGIN/g" "/home/$LOGIN/"public_html/index.php
sed -i "s/<<USER>>/$LOGIN/g" "/home/$LOGIN/"public_html/parts/header.php
sed -i "s/<<USER>>/$LOGIN/g" "/home/$LOGIN/"public_html/blog/index.php
mkdir -p "/home/$LOGIN/".config/weechat/
cp /root/helpers/irc.conf "/home/$LOGIN/".config/weechat
cat << EOF > "/home/$LOGIN/.profile"
if [ -z "\$TMUX" ]; then
exec tmux attach -t main || exec tmux new -s main