38 lines
794 B
Plaintext
38 lines
794 B
Plaintext
|
#!/bin/bash
|
||
|
|
||
|
MY_USERNAME=$1
|
||
|
|
||
|
if [ ! $MY_USERNAME ]; then
|
||
|
echo 'Please specify a username to remove'
|
||
|
exit 1
|
||
|
fi
|
||
|
|
||
|
if [ ! -d /home/$MY_USERNAME ]; then
|
||
|
echo "Home directory does not exist for $MY_USERNAME"
|
||
|
exit 2
|
||
|
fi
|
||
|
|
||
|
if [ -f /home/$MY_USERNAME/.freedombone_administrator ]; then
|
||
|
echo "The administrator user cannot be removed"
|
||
|
exit 3
|
||
|
fi
|
||
|
|
||
|
echo '>>> REMOVE USER <<<'
|
||
|
read -p "Do you really wish to remove the user '$MY_USERNAME' (y/n) ?" yn
|
||
|
if [[ $yn != 'y' && $yn != 'Y' && $yn != 'yes' && $yn != 'Yes' && $yn != 'YES' ]]; then
|
||
|
echo "User $MY_USERNAME was not removed"
|
||
|
exit 4
|
||
|
fi
|
||
|
|
||
|
freedombone-rmxmpp -e "$MY_USERNAME@$HOSTNAME"
|
||
|
|
||
|
userdel -r $MY_USERNAME
|
||
|
|
||
|
if [ -d /home/$MY_USERNAME ]; then
|
||
|
rm -rf /home/$MY_USERNAME
|
||
|
fi
|
||
|
|
||
|
echo "User $MY_USERNAME was removed"
|
||
|
|
||
|
exit 0
|