forked from vern/scripts
fix pubnixvm
This commit is contained in:
parent
27427423a3
commit
7ee3902022
|
@ -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 '<home-manager>' -A install
|
||||
printf "%s\n%s\n" "$2" "$2" | passwd "$1"
|
||||
zfs set userquota@"${1}"=20G pool1/home
|
|
@ -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
|
|
@ -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 ||:
|
|
@ -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
|
Loading…
Reference in New Issue