Added uninstall and fixed freescout to have uninstall

This commit is contained in:
root 2023-12-19 16:12:30 +00:00
parent 0cb8a6039c
commit 08fae37716
2 changed files with 45 additions and 0 deletions

27
bin/uninstallapp Executable file
View File

@ -0,0 +1,27 @@
#!/bin/bash
#
# Uninstalls app
# This will completely remove database and files
. /etc/federated
. /federated/lib/functions.sh
trap cleanup `seq 1 15`
usage() {
cat << EOF
UnInstall application
Usage: $0 appname
Arguments:
appname Application to remove. bookstack,espocrm,freescout,etc
This will completely remove database and files
EOF
exit 2;
}
[ $# != 1 ] && usage
APP=$1
[ ! -f /federated/lib/$APP.sh ] && failcheck "/federated/lib/$APP.sh doesn't exist."
[ ! -d /federated/apps/$APP ] && failcheck "/federated/apps/$APP doesn't exists. $APP is already uninstalled?"
. /federated/lib/$APP.sh
uninstall_$APP

View File

@ -168,3 +168,21 @@ EOF
kill -9 $SPINPID &> /dev/null kill -9 $SPINPID &> /dev/null
echo -ne "done.\n" echo -ne "done.\n"
} }
uninstall_freescout() {
echo -ne "* Uninstalling freescout container.."
spin &
SPINPID=$!
# First stop the service
cd /federated/apps/freescout && docker-compose -f docker-compose.yml -p freescout down &> /dev/null
# Delete database and user in postgresql
docker exec postgresql psql -U postgres -c "DROP DATABASE freescout" &> /dev/null
docker exec postgresql psql -U postgres -c "DROP USER freescout" &> /dev/null
# Delete the app directory
rm -rf /federated/apps/freescout
kill -9 $SPINPID &> /dev/null
echo -ne "done.\n"
}