forked from vern/scripts
30 lines
1.0 KiB
Bash
Executable File
30 lines
1.0 KiB
Bash
Executable File
#!/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"
|
|
chmod 755 "$_HOME/public_gcdn"
|
|
systemctl restart gemini
|
|
sed -i "s/USER/${1}/g" "$_HOME"/.config/nixpkgs/home.nix
|
|
sed -i "s/replaceme/${1}/g" "$_HOME"/.config/aerc/accounts.conf
|
|
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
|
|
sudo -u postgres psql -c "create role ${1};"
|
|
sudo -u postgres createdb -O ${1} ${1}
|