makeuser/rmuser

34 lines
838 B
Plaintext
Raw Normal View History

#!/bin/bash
2019-12-06 15:40:49 +00:00
CONFIG=./setenv
. $CONFIG
if [ -z $1 ]
then
2020-04-29 22:46:28 +00:00
echo -e "Usage: `basename $0` [ username | --baned ]"
else
remove_user $1
2020-04-29 22:46:28 +00:00
[ -n $2 ] && [[ $2 == --banned ]] && echo $1 >> /root/users.banned
fi
remove_user()
{
echo "This will remove user account $1 from Thunix."
echo "It is assumed the user account has been un-enforced in Ansible as well."
echo "Unsubscribe from this list..."
echo "From: $1 Subject: unsubscribe " | sudo -u $1 mail $LIST_NAME
2019-05-14 11:36:41 +00:00
echo "Killing user processes..."
sudo pkill -9 -U $1
2019-05-14 11:36:41 +00:00
echo "Archiving home dir..."
sudo tar cfz /root/backups/$1.tgz /home/$1
sudo rm -rf /home/$1
2019-05-14 11:36:41 +00:00
echo "Deleting account from system..."
sudo userdel $1
2019-12-12 20:28:16 +00:00
echo "User $1 removed from system. Make sure user is unenforced in ansible." | sudo mail -s "User Account $1 removed from Thunix" $ADMIN_EMAIL
}