Compare commits
9 Commits
editor
...
6cbfe67660
| Author | SHA1 | Date | |
|---|---|---|---|
| 6cbfe67660 | |||
| 08983174b8 | |||
| 76e4eb751d | |||
| fc15f8fff7 | |||
| 59f1607812 | |||
| 4f00bccbe5 | |||
| f082adf206 | |||
|
|
9381838e4f | ||
|
|
62cdc6a67d |
12
active-users
Executable file
12
active-users
Executable file
@@ -0,0 +1,12 @@
|
||||
#!/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);
|
||||
?>
|
||||
44
add_user.sh
44
add_user.sh
@@ -7,18 +7,22 @@ set -e
|
||||
LOGIN="$1"
|
||||
[ -z "$LOGIN" ] && { echo "Użycie: $0 <login>"; exit 1; }
|
||||
|
||||
setup_user() {
|
||||
STEP=$2
|
||||
PASS="$(openssl rand -base64 16 | sed 's/[\/\+\=\\]//g')"
|
||||
|
||||
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/"
|
||||
|
||||
|
||||
Reference in New Issue
Block a user