Different way of recording the admin user

This commit is contained in:
Bob Mottram 2015-10-27 10:28:46 +00:00
parent 4aadbbd32c
commit 5ee011f200
2 changed files with 22 additions and 5 deletions

View File

@ -1231,8 +1231,8 @@ function install_not_on_BBB {
} }
function mark_admin_user_account { function mark_admin_user_account {
if [ ! -f /home/$MY_USERNAME/.freedombone_administrator ]; then if ! grep -q "Admin user:" $COMPLETION_FILE; then
touch /home/$MY_USERNAME/.freedombone_administrator echo "Admin user:$MY_USERNAME" >> $COMPLETION_FILE
fi fi
} }

View File

@ -12,16 +12,33 @@ if [ ! -d /home/$MY_USERNAME ]; then
exit 2 exit 2
fi fi
if [ -f /home/$MY_USERNAME/.freedombone_administrator ]; then COMPLETION_FILE=$HOME/freedombone-completed.txt
echo "The administrator user cannot be removed" if [ ! -f $COMPLETION_FILE ]; then
echo "$COMPLETION_FILE not found"
exit 3 exit 3
fi fi
if ! grep -q "Admin user" $CONFIGURATION_FILE; then
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
echo '>>> REMOVE USER <<<' echo '>>> REMOVE USER <<<'
read -p "Do you really wish to remove the user '$MY_USERNAME' (y/n) ?" yn 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 if [[ $yn != 'y' && $yn != 'Y' && $yn != 'yes' && $yn != 'Yes' && $yn != 'YES' ]]; then
echo "User $MY_USERNAME was not removed" echo "User $MY_USERNAME was not removed"
exit 4 exit 7
fi fi
freedombone-rmxmpp -e "$MY_USERNAME@$HOSTNAME" freedombone-rmxmpp -e "$MY_USERNAME@$HOSTNAME"