diff --git a/pubnixvm b/pubnixvm deleted file mode 120000 index 6019709..0000000 --- a/pubnixvm +++ /dev/null @@ -1 +0,0 @@ -/sshfs/root/bin/ \ No newline at end of file diff --git a/pubnixvm/mktuser b/pubnixvm/mktuser new file mode 100755 index 0000000..33b3853 --- /dev/null +++ b/pubnixvm/mktuser @@ -0,0 +1,28 @@ +#!/usr/bin/env -S bash -e + + + +[[ -z "$2" ]] && { + printf 'Usage: %s username password [user|admin] [shell] <<< pubkey\n' "$0" + exit 1 +} + +PREFIX="/home" +_HOME="$PREFIX/$1" + +useradd -Umd "$_HOME" -s "${4:-/run/current-system/sw/bin/bash}" "$1" $([[ "$3" == "admin" ]] && printf -- '-G wheel') +# useradd -Umd "$_HOME" -s "${4:-/bin/bash}" "$1" -G "mail$([[ "$3" == "admin" ]] && printf ',wheel')" +mkdir "$_HOME/.ssh" +cat > "$_HOME/.ssh/authorized_keys" +chown -R "$1:$1" "$_HOME/.ssh" +find "$_HOME" -type d -exec chmod 700 {} \; +find "$_HOME" -type f -exec chmod 600 {} \; +chmod 711 "$_HOME" +chmod 755 "$_HOME/public_html" +chmod 755 "$_HOME/public_gemini" +chmod 755 "$_HOME/public_gopher" +systemctl restart gemini +sed -i "s/USER/${1}/g" "$_HOME"/.config/nixpkgs/home.nix +sudo -u $1 nix-shell '' -A install +printf "%s\n%s\n" "$2" "$2" | passwd "$1" +zfs set userquota@"${1}"=20G pool1/home diff --git a/pubnixvm/reboot b/pubnixvm/reboot new file mode 100755 index 0000000..433e399 --- /dev/null +++ b/pubnixvm/reboot @@ -0,0 +1,30 @@ +#!/usr/bin/env -S bash -e + +[[ -z $1 ]] && { + printf 'Usage: %s N\nN must be a positive or zero integer\n' "$0" >&2 + exit 1 +} + +[[ "$1" -ge 0 ]] 2> /dev/null || { + printf 'Expected non-negative integer, got `%s'\''\n' "$1" >&2 + exit 2 +} + +print_to_ttys() { + who | while read -r _ TTY _; do + printf "Printing to %s\n" "$TTY" + printf "$@" > /dev/$TTY + done +} + +print_to_ttys "\nRebooting in %d seconds, please save your work\n" "$1" + +if [[ "$1" -gt 5 ]]; then + read -t "$(($1-5))" <><(:)||: + print_to_ttys "\nRebooting in %d seconds\n" 5 + read -t 5 <><(:)||: +else + read -t $1 <><(:)||: +fi + +systemctl reboot diff --git a/pubnixvm/remind b/pubnixvm/remind new file mode 100755 index 0000000..1032637 --- /dev/null +++ b/pubnixvm/remind @@ -0,0 +1,9 @@ +#!/usr/bin/env -S bash -e + +[[ -z "$@" ]] && set -- $(tty) + +TMP=$(ls /var/tmp/register | wc -l) +[[ $TMP > 0 ]] && + for FILE in "$@"; do + [[ "$FILE" != *ptmx ]] && printf '\nTHERE ARE %d UNCHECKED MEMBERSHIP REQUESTS.\n' "$TMP" > $FILE + done ||: diff --git a/pubnixvm/remindall b/pubnixvm/remindall new file mode 100755 index 0000000..ad2d15a --- /dev/null +++ b/pubnixvm/remindall @@ -0,0 +1,3 @@ +#!/usr/bin/env -S bash -e + +w | while read -r U P _; do [[ $U == root ]] && /root/bin/remind /dev/$P; done