2015-10-26 16:11:37 +01:00
|
|
|
#!/bin/bash
|
|
|
|
|
2015-11-27 12:42:16 +01:00
|
|
|
PROJECT_NAME='freedombone'
|
|
|
|
|
|
|
|
export TEXTDOMAIN=$PROJECT_NAME
|
|
|
|
export TEXTDOMAINDIR="/usr/share/locale"
|
|
|
|
|
2015-10-26 16:11:37 +01:00
|
|
|
MY_USERNAME=$1
|
2015-10-27 11:50:41 +01:00
|
|
|
COMPLETION_FILE=$HOME/freedombone-completed.txt
|
2015-10-26 16:11:37 +01:00
|
|
|
|
|
|
|
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
|
|
|
|
|
2015-10-27 11:28:46 +01:00
|
|
|
if [ ! -f $COMPLETION_FILE ]; then
|
|
|
|
echo "$COMPLETION_FILE not found"
|
2015-10-26 16:11:37 +01:00
|
|
|
exit 3
|
|
|
|
fi
|
|
|
|
|
2015-10-27 12:14:08 +01:00
|
|
|
if ! grep -q "Admin user" $COMPLETION_FILE; then
|
2015-10-27 11:28:46 +01:00
|
|
|
echo "No admin user specified in $COMPLETION_FILE"
|
|
|
|
exit 4
|
|
|
|
fi
|
|
|
|
|
|
|
|
ADMIN_USERNAME=$(cat $COMPLETION_FILE | grep "Admin user" | awk -F ':' '{print $2}')
|
|
|
|
if [ ! $ADMIN_USERNAME ]; then
|
|
|
|
echo "No admin username specified in $COMPLETION_FILE"
|
|
|
|
exit 5
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [[ $MY_USERNAME == $ADMIN_USERNAME ]]; then
|
|
|
|
echo "The administrator user cannot be removed"
|
|
|
|
exit 6
|
|
|
|
fi
|
|
|
|
|
2015-10-26 16:11:37 +01:00
|
|
|
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"
|
2015-10-27 11:28:46 +01:00
|
|
|
exit 7
|
2015-10-26 16:11:37 +01:00
|
|
|
fi
|
|
|
|
|
2015-11-02 11:56:02 +01:00
|
|
|
if grep -q "install_xmpp" $COMPLETION_FILE; then
|
|
|
|
freedombone-rmxmpp -e "$MY_USERNAME@$HOSTNAME"
|
|
|
|
fi
|
2015-10-26 16:11:37 +01:00
|
|
|
|
2015-10-27 11:50:41 +01:00
|
|
|
if grep -q "Blog domain" $COMPLETION_FILE; then
|
|
|
|
FULLBLOG_DOMAIN_NAME=$(cat $COMPLETION_FILE | grep "Blog domain" | awk -F ':' '{print $2}')
|
|
|
|
if [ -f /var/www/$FULLBLOG_DOMAIN_NAME/htdocs/config/users/$MY_USERNAME.ini ]; then
|
|
|
|
rm /var/www/$FULLBLOG_DOMAIN_NAME/htdocs/config/users/$MY_USERNAME.ini
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
2015-11-02 11:56:02 +01:00
|
|
|
if grep -q "install_sip" $COMPLETION_FILE; then
|
|
|
|
freedombone-rmsipuser $MY_USERNAME
|
|
|
|
fi
|
|
|
|
|
2015-11-10 18:56:10 +01:00
|
|
|
#if grep -q "install_owncloud" $COMPLETION_FILE; then
|
|
|
|
# occ user:delete $MY_USERNAME
|
|
|
|
#fi
|
2015-11-10 13:20:55 +01:00
|
|
|
|
2015-10-26 16:11:37 +01:00
|
|
|
userdel -r $MY_USERNAME
|
|
|
|
|
|
|
|
if [ -d /home/$MY_USERNAME ]; then
|
|
|
|
rm -rf /home/$MY_USERNAME
|
|
|
|
fi
|
|
|
|
|
|
|
|
echo "User $MY_USERNAME was removed"
|
|
|
|
|
|
|
|
exit 0
|