Compare commits
1 Commits
main
...
4901af38b4
| Author | SHA1 | Date | |
|---|---|---|---|
| 4901af38b4 |
12
active-users
12
active-users
@@ -1,12 +0,0 @@
|
|||||||
#!/usr/bin/php
|
|
||||||
<?php
|
|
||||||
$jsonFile = '/opt/html/online.json';
|
|
||||||
|
|
||||||
$activeUsers = shell_exec("ps -eo user=,comm= | awk '$2 ~ /sshd/ {print $1}' | grep -vE 'sshd|root' | sort -u");
|
|
||||||
|
|
||||||
$activeUsersArray = array_filter(explode("\n", $activeUsers));
|
|
||||||
|
|
||||||
$activeUsersJson = json_encode($activeUsersArray, JSON_PRETTY_PRINT);
|
|
||||||
|
|
||||||
file_put_contents($jsonFile, $activeUsersJson);
|
|
||||||
?>
|
|
||||||
46
add_user.sh
46
add_user.sh
@@ -7,22 +7,18 @@ set -e
|
|||||||
LOGIN="$1"
|
LOGIN="$1"
|
||||||
[ -z "$LOGIN" ] && { echo "Użycie: $0 <login>"; exit 1; }
|
[ -z "$LOGIN" ] && { echo "Użycie: $0 <login>"; exit 1; }
|
||||||
|
|
||||||
STEP=$2
|
setup_user() {
|
||||||
PASS="$(openssl rand -base64 16 | sed 's/[\/\+\=\\]//g')"
|
|
||||||
|
|
||||||
add_user() {
|
|
||||||
adduser -D -s /bin/sh -h "/home/$LOGIN" -H "$LOGIN"
|
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
|
echo "$LOGIN":"$PASS" | chpasswd
|
||||||
|
|
||||||
zfs create -o mountpoint="/home/$LOGIN" -o quota=200M "tank/ROOT/homes/$LOGIN"
|
zfs create -o mountpoint="/home/$LOGIN" -o quota=200M "tank/ROOT/homes/$LOGIN"
|
||||||
chown "$LOGIN":"$LOGIN" "/home/$LOGIN"
|
chown "$LOGIN":"$LOGIN" "/home/$LOGIN"
|
||||||
}
|
|
||||||
|
|
||||||
setup_user() {
|
|
||||||
addgroup "$LOGIN" tildeusers
|
|
||||||
|
|
||||||
# neomutt had issues with default vi
|
# neomutt had issues with default vi
|
||||||
echo "export EDITOR=nvim" >> "/home/$LOGIN/.ashrc"
|
cat "export EDITOR=nvim" >> "/home/$LOGIN/.ashrc"
|
||||||
|
|
||||||
# set cgroup
|
# set cgroup
|
||||||
CG_ROOT=/sys/fs/cgroup/users
|
CG_ROOT=/sys/fs/cgroup/users
|
||||||
@@ -115,6 +111,11 @@ setup_weechat () {
|
|||||||
}
|
}
|
||||||
|
|
||||||
send_welcome_mail () {
|
send_welcome_mail () {
|
||||||
|
cp welcome_tmp.txt welcome.txt
|
||||||
|
|
||||||
|
echo "Login: $LOGIN" >> welcome.txt
|
||||||
|
echo "Hasło: $PASS" >> welcome.txt
|
||||||
|
|
||||||
sendmail -f v0id1st@tylda.org "$LOGIN@tylda.org" << EOF
|
sendmail -f v0id1st@tylda.org "$LOGIN@tylda.org" << EOF
|
||||||
Subject: Witaj na tylda.org!
|
Subject: Witaj na tylda.org!
|
||||||
From: v0id1st@tylda.org
|
From: v0id1st@tylda.org
|
||||||
@@ -128,27 +129,18 @@ Twoje dane do Nextcloud to (https://cloud.tylda.org) to:
|
|||||||
EOF
|
EOF
|
||||||
}
|
}
|
||||||
|
|
||||||
if [ -z "$STEP" ]; then
|
setup_user
|
||||||
# critical path
|
setup_neomutt
|
||||||
add_user
|
setup_tmux
|
||||||
setup_user
|
setup_gemini
|
||||||
setup_nextcloud
|
setup_html
|
||||||
send_welcome_mail
|
setup_weechat
|
||||||
|
setup_nextcloud
|
||||||
# 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/"
|
chown -R "$LOGIN":"$LOGIN" "/home/$LOGIN/"
|
||||||
|
|
||||||
|
send_welcome_mail
|
||||||
|
|
||||||
echo 524288000 > "$USER_CG/memory.max" # 500 MB RAM
|
echo 524288000 > "$USER_CG/memory.max" # 500 MB RAM
|
||||||
echo "50000 100000" > "$USER_CG/cpu.max" # 50 % CPU (quota/period μs)
|
echo "50000 100000" > "$USER_CG/cpu.max" # 50 % CPU (quota/period μs)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user