vern-scripts/tilserv/delete

25 lines
941 B
Bash
Executable File

#!/usr/bin/env -S bash
[[ -z "$1" ]] && {
printf 'Usage: %s username\n' "$0"
exit 1
}
#[[ -d "/sshfs/home/$1" ]] || {
# printf "User %s does not exist\n" "$1"
# exit 2
#}
read -rp "Delete user $1? [y/N] "
[[ $REPLY =~ [Yy] ]] && {
ssh 192.168.122.30 "tar -zcpvf - /home/${1}" > ~/"${1}"-data.tar.gz
ssh 192.168.122.30 "userdel -r '$1'; groupdel '$1'"
curl -XPOST -H "Authorization: Bearer $(</root/priv/root-access-token)" -H "Content-Type: application/json" -d '{"erase":true}' "http://localhost:8008/_synapse/admin/v1/deactivate/@$1:vern.cc"
su - mastodon -c "live/bin/tootctl accounts delete $1"
su - git -c "gitea admin user delete --username $1 -c /etc/gitea/app.ini"
prosodyctl deluser "$1"@vern.cc
prosodyctl deluser "$1"@jitsi.vern.cc
prosodyctl deluser "$1"@vernccvbvyi5qhfzyqengccj7lkove6bjot2xhh5kajhwvidqafczrad.onion
prosodyctl deluser "$1"@verncceu2kgz54wi7r5jatgmx2mqtsh3knxhiy4m5shescuqtqfa.b32.i2p
} || exit 3