Removing a user from apps

This commit is contained in:
Bob Mottram 2016-10-02 11:17:01 +01:00
parent 164302b0c9
commit f4f50eaf02
7 changed files with 82 additions and 60 deletions

View File

@ -38,9 +38,18 @@ FULLBLOG_COMMIT='bf5fe9486160be4da86d8987d3e5c977e1dc6d32'
MY_BLOG_TITLE="My Blog"
MY_BLOG_SUBTITLE="Another ${PROJECT_NAME} Blog"
function remove_user_blog {
remove_username="$1"
FULLBLOG_DOMAIN_NAME=$(cat $COMPLETION_FILE | grep "blog domain" | head -n 1 | awk -F ':' '{print $2}')
if [ -f /var/www/${FULLBLOG_DOMAIN_NAME}/htdocs/config/users/${remove_username}.ini ]; then
rm /var/www/${FULLBLOG_DOMAIN_NAME}/htdocs/config/users/${remove_username}.ini
fi
}
function add_user_blog {
if [[ $(app_is_installed blog) == "0" ]]; then
echo '1'
echo '0'
return
fi

View File

@ -56,12 +56,17 @@ GNUSOCIAL_NSFW_COMMIT='a096bbe0cfae9a9b177682920ffb58d32a48e136'
# script which causes old posts to expire
gnusocial_expire_script=/usr/bin/gnusocial-expire
function add_user_gnusocial {
if [[ $(app_is_installed gnusocial) == "0" ]]; then
echo '1'
return
fi
function remove_user_gnusocial {
remove_username="$1"
MICROBLOG_DOMAIN_NAME=$(cat $COMPLETION_FILE | grep "gnusocial domain" | head -n 1 | awk -F ':' '{print $2}')
if [ -d /var/www/$MICROBLOG_DOMAIN_NAME ]; then
cd /var/www/$MICROBLOG_DOMAIN_NAME/htdocs
php scripts/deleteprofile.php -n $remove_username -y
fi
}
function add_user_gnusocial {
new_username="$1"
new_user_password="$2"
@ -72,7 +77,7 @@ function add_user_gnusocial {
${PROJECT_NAME}-addemail -u $new_username -e "noreply@$MICROBLOG_DOMAIN_NAME" -g gnusocial --public no
echo '0'
else
echo '2'
echo '1'
fi
}

View File

@ -36,12 +36,18 @@ IRC_ONION_PORT=6697
# An optional password to log into IRC. This applies to all users
IRC_PASSWORD=
function add_user_irc {
if [[ $(app_is_installed irc) == "0" ]]; then
echo '1'
return
fi
function remove_user_irc {
remove_username="$1"
if [ -d /home/$remove_username/.irssi ]; then
rm -rf /home/$remove_username/.irssi
fi
if [ -d /home/$remove_username/irclogs ]; then
rm -rf /home/$remove_username/irclogs
fi
}
function add_user_irc {
new_username="$1"
new_user_password="$2"

View File

@ -37,19 +37,24 @@ TURN_PORT=3478
TURN_TLS_PORT=5349
TURN_NONCE=
function add_user_sip {
if [[ $(app_is_installed sip) == "0" ]]; then
echo '1'
return
fi
function remove_user_sip {
remove_username="$1"
${PROJECT_NAME}-rmsipuser ${remove_username}
# remove user from SIP TURN/STUN
if [ -f /etc/turnserver/turnusers.txt ]; then
sed -i "/${remove_username}:/d" /etc/turnserver/turnusers.txt
fi
}
function add_user_sip {
new_username="$1"
new_user_password="$2"
SIP_EXTENSION=$(${PROJECT_NAME}-sipfreeext)
${PROJECT_NAME}-addsipuser -u $new_username -e $SIP_EXTENSION -p "$new_user_password"
if [ ! "$?" = "0" ]; then
echo '2'
echo '1'
return
fi

View File

@ -49,6 +49,18 @@ TOXIC_FILE=/usr/local/bin/toxic
QTOX_REPO="https://github.com/bashrc/qTox"
QTOX_COMMIT='27a628a3789fca4f31516c3982e580052dd3c773'
function remove_user_tox {
remove_username="$1"
if [ -d /home/$remove_username/.config/tox ]; then
if [ -d /home/$remove_username/.config/tox/chatlogs ]; then
shred -zu /home/$remove_username/.config/tox/chatlogs/*
rm -rf /home/$remove_username/.config/tox/chatlogs
fi
shred -zu /home/$remove_username/.config/tox/*
fi
}
function run_client_tox {
# create a tox user
USER_TOX_FILE=/home/${USER}/.config/tox/data.tox

View File

@ -37,18 +37,18 @@ XMPP_PASSWORD=
XMPP_CIPHERS='"EDH+CAMELLIA:EDH+aRSA:EECDH+aRSA+AESGCM:EECDH+aRSA+SHA256:EECDH:+CAMELLIA128:+AES128:+SSLv3:!aNULL:!eNULL:!LOW:!3DES:!MD5:!EXP:!PSK:!DSS:!RC4:!SEED:!IDEA:!ECDSA:kEDH:CAMELLIA128-SHA:AES128-SHA"'
XMPP_ECC_CURVE='"secp384r1"'
function add_user_xmpp {
if [[ $(app_is_installed xmpp) == "0" ]]; then
echo '1'
return
fi
function remove_user_xmpp {
remove_username="$1"
${PROJECT_NAME}-rmxmpp -e "${remove_username}@$HOSTNAME"
}
function add_user_xmpp {
new_username="$1"
new_user_password="$2"
${PROJECT_NAME}-addxmpp -e "$new_username@$HOSTNAME" -p "$new_user_password"
if [ ! "$?" = "0" ]; then
echo '2'
echo '1'
return
fi

View File

@ -37,6 +37,18 @@ export TEXTDOMAINDIR="/usr/share/locale"
MY_USERNAME=$1
COMPLETION_FILE=$HOME/${PROJECT_NAME}-completed.txt
UTILS_FILES=/usr/share/${PROJECT_NAME}/utils/${PROJECT_NAME}-utils-*
for f in $UTILS_FILES
do
source $f
done
APP_FILES=/usr/share/${PROJECT_NAME}/apps/${PROJECT_NAME}-app-*
for f in $APP_FILES
do
source $f
done
if [ ! $MY_USERNAME ]; then
echo $'Please specify a username to remove'
exit 1
@ -80,41 +92,12 @@ if [[ $yn != 'y' && $yn != 'Y' && $yn != 'yes' && $yn != 'Yes' && $yn != 'YES' ]
exit 8
fi
if grep -q "install_xmpp" $COMPLETION_FILE; then
${PROJECT_NAME}-rmxmpp -e "$MY_USERNAME@$HOSTNAME"
fi
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
if grep -q "install_sip" $COMPLETION_FILE; then
${PROJECT_NAME}-rmsipuser $MY_USERNAME
fi
if grep -q "gnusocial domain" $COMPLETION_FILE; then
MICROBLOG_DOMAIN_NAME=$(cat $COMPLETION_FILE | grep "gnusocial domain" | awk -F ':' '{print $2}')
if [ -d /var/www/$MICROBLOG_DOMAIN_NAME ]; then
cd /var/www/$MICROBLOG_DOMAIN_NAME/htdocs
php scripts/deleteprofile.php -n $MY_USERNAME -y
echo $'Removed gnusocial user'
fi
fi
if [ -f /etc/nginx/.htpasswd ]; then
if grep "${MY_USERNAME}:" /etc/nginx/.htpasswd; then
htpasswd -D /etc/nginx/.htpasswd $MY_USERNAME
fi
fi
# remove user from SIP TURN/STUN
if [ -d /etc/turnserver ]; then
sed -i "/${MY_USERNAME}:/d" /etc/turnserver/turnusers.txt
fi
# remove gpg keys
if [ -d /home/$MY_USERNAME/.gnupg ]; then
shred -zu /home/$MY_USERNAME/.gnupg/*
@ -125,14 +108,16 @@ if [ -d /home/$MY_USERNAME/.ssh ]; then
shred -zu /home/$MY_USERNAME/.ssh/*
fi
# remove tox indentity
if [ -d /home/$MY_USERNAME/.config/tox ]; then
if [ -d /home/$MY_USERNAME/.config/tox/chatlogs ]; then
shred -zu /home/$MY_USERNAME/.config/tox/chatlogs/*
rm -rf /home/$MY_USERNAME/.config/tox/chatlogs
echo $'Detecting installed apps...'
detect_apps
get_apps_installed_names
for app_name in "${APPS_INSTALLED_NAMES[@]}"
do
if [[ $(function_exists remove_user_${app_name}) == "1" ]]; then
echo $"Removing user from ${app_name}"
remove_user_${app_name} "$MY_USERNAME"
fi
shred -zu /home/$MY_USERNAME/.config/tox/*
fi
done
userdel -r $MY_USERNAME