Update uninstall script not to fail on clean installation

This commit is contained in:
Disassembler 2018-10-31 08:28:26 +01:00
parent f98edaff58
commit a339c8e8ff
Signed by: Disassembler
GPG Key ID: 524BD33A0EE29499
17 changed files with 101 additions and 61 deletions

View File

@ -10,18 +10,24 @@ rm -f /etc/init.d/ckan
rc-update -u
# Drop database and user
[ ! -e /run/openrc/started/postgres ] && service postgres start && STOP_POSTGRES=1
echo 'DROP DATABASE ckan; DROP DATABASE ckan_datastore; DROP ROLE ckan; DROP ROLE ckan_datastore;' | lxc-attach -u 5432 -g 5432 postgres -- psql
[ ! -z ${STOP_POSTGRES} ] && service postgres stop
if [ -e /etc/init.d/postgres ]; then
[ ! -e /run/openrc/started/postgres ] && service postgres start && STOP_POSTGRES=1
echo 'DROP DATABASE ckan; DROP DATABASE ckan_datastore; DROP ROLE ckan; DROP ROLE ckan_datastore;' | lxc-attach -u 5432 -g 5432 postgres -- psql
[ ! -z ${STOP_POSTGRES} ] && service postgres stop
fi
# Remove redis data
[ ! -e /run/openrc/started/redis ] && service redis start && STOP_REDIS=1
lxc-attach redis -- redis-cli -n 0 flushdb
[ ! -z ${STOP_REDIS} ] && service redis stop
if [ -e /etc/init.d/redis ]; then
[ ! -e /run/openrc/started/redis ] && service redis start && STOP_REDIS=1
lxc-attach redis -- redis-cli -n 0 flushdb
[ ! -z ${STOP_REDIS} ] && service redis stop
fi
# Remove solr core
[ -e /run/openrc/started/solr ] && service solr stop && START_SOLR=1
rm -rf /srv/solr/data/ckan
[ ! -z ${START_SOLR} ] && service solr start
if [ -e /etc/init.d/solr ]; then
[ -e /run/openrc/started/solr ] && service solr stop && START_SOLR=1
rm -rf /srv/solr/data/ckan
[ ! -z ${START_SOLR} ] && service solr start
fi
exit 0

View File

@ -7,8 +7,10 @@ rm -f /etc/init.d/crisiscleanup
rc-update -u
# Drop database and user
[ ! -e /run/openrc/started/postgres ] && service postgres start && STOP_POSTGRES=1
echo 'DROP DATABASE crisiscleanup; DROP ROLE crisiscleanup;' | lxc-attach -u 5432 -g 5432 postgres -- psql
[ ! -z ${STOP_POSTGRES} ] && service postgres stop
if [ -e /etc/init.d/postgres ]; then
[ ! -e /run/openrc/started/postgres ] && service postgres start && STOP_POSTGRES=1
echo 'DROP DATABASE crisiscleanup; DROP ROLE crisiscleanup;' | lxc-attach -u 5432 -g 5432 postgres -- psql
[ ! -z ${STOP_POSTGRES} ] && service postgres stop
fi
exit 0

View File

@ -7,8 +7,10 @@ rm -f /etc/init.d/cts
rc-update -u
# Drop database and user
[ ! -e /run/openrc/started/postgres ] && service postgres start && STOP_POSTGRES=1
echo 'DROP DATABASE cts; DROP ROLE cts;' | lxc-attach -u 5432 -g 5432 postgres -- psql
[ ! -z ${STOP_POSTGRES} ] && service postgres stop
if [ -e /etc/init.d/postgres ]; then
[ ! -e /run/openrc/started/postgres ] && service postgres start && STOP_POSTGRES=1
echo 'DROP DATABASE cts; DROP ROLE cts;' | lxc-attach -u 5432 -g 5432 postgres -- psql
[ ! -z ${STOP_POSTGRES} ] && service postgres stop
fi
exit 0

View File

@ -7,8 +7,10 @@ rm -f /etc/init.d/gnuhealth
rc-update -u
# Drop database and user
[ ! -e /run/openrc/started/postgres ] && service postgres start && STOP_POSTGRES=1
echo 'DROP DATABASE gnuhealth; DROP DATABASE gnuhealth_demo; DROP ROLE gnuhealth;' | lxc-attach -u 5432 -g 5432 postgres -- psql
[ ! -z ${STOP_POSTGRES} ] && service postgres stop
if [ -e /etc/init.d/postgres ]; then
[ ! -e /run/openrc/started/postgres ] && service postgres start && STOP_POSTGRES=1
echo 'DROP DATABASE gnuhealth; DROP DATABASE gnuhealth_demo; DROP ROLE gnuhealth;' | lxc-attach -u 5432 -g 5432 postgres -- psql
[ ! -z ${STOP_POSTGRES} ] && service postgres stop
fi
exit 0

View File

@ -10,8 +10,10 @@ rm -f /etc/init.d/kanboard
rc-update -u
# Drop database and user
[ ! -e /run/openrc/started/postgres ] && service postgres start && STOP_POSTGRES=1
echo 'DROP DATABASE kanboard; DROP ROLE kanboard;' | lxc-attach -u 5432 -g 5432 postgres -- psql
[ ! -z ${STOP_POSTGRES} ] && service postgres stop
if [ -e /etc/init.d/postgres ]; then
[ ! -e /run/openrc/started/postgres ] && service postgres start && STOP_POSTGRES=1
echo 'DROP DATABASE kanboard; DROP ROLE kanboard;' | lxc-attach -u 5432 -g 5432 postgres -- psql
[ ! -z ${STOP_POSTGRES} ] && service postgres stop
fi
exit 0

View File

@ -7,8 +7,10 @@ rm -f /etc/init.d/mifosx
rc-update -u
# Drop database and user
[ ! -e /run/openrc/started/mariadb ] && service mariadb start && STOP_MARIADB=1
echo 'DROP DATABASE `mifosplatform-tenants`; DROP DATABASE `mifostenant-default`; DROP USER `mifosx`;' | lxc-attach mariadb -- mysql
[ ! -z ${STOP_MARIADB} ] && service mariadb stop
if [ -e /etc/init.d/mariadb ]; then
[ ! -e /run/openrc/started/mariadb ] && service mariadb start && STOP_MARIADB=1
echo 'DROP DATABASE `mifosplatform-tenants`; DROP DATABASE `mifostenant-default`; DROP USER `mifosx`;' | lxc-attach mariadb -- mysql
[ ! -z ${STOP_MARIADB} ] && service mariadb stop
fi
exit 0

View File

@ -7,9 +7,11 @@ rm -f /etc/init.d/motech
rc-update -u
# Drop database and user
[ ! -e /run/openrc/started/postgres ] && service postgres start && STOP_POSTGRES=1
echo 'DROP DATABASE motech; DROP DATABASE motechdata; DROP DATABASE motechquartz; DROP DATABASE motechschema; DROP ROLE motech;' | lxc-attach -u 5432 -g 5432 postgres -- psql
[ ! -z ${STOP_POSTGRES} ] && service postgres stop
if [ -e /etc/init.d/postgres ]; then
[ ! -e /run/openrc/started/postgres ] && service postgres start && STOP_POSTGRES=1
echo 'DROP DATABASE motech; DROP DATABASE motechdata; DROP DATABASE motechquartz; DROP DATABASE motechschema; DROP ROLE motech;' | lxc-attach -u 5432 -g 5432 postgres -- psql
[ ! -z ${STOP_POSTGRES} ] && service postgres stop
fi
# TODO: Clear ActiveMQ config

View File

@ -7,8 +7,10 @@ rm -f /etc/init.d/opendatakit-build
rc-update -u
# Drop database and user
[ ! -e /run/openrc/started/postgres ] && service postgres start && STOP_POSTGRES=1
echo 'DROP DATABASE opendatakitbuild; DROP ROLE opendatakitbuild;' | lxc-attach -u 5432 -g 5432 postgres -- psql
[ ! -z ${STOP_POSTGRES} ] && service postgres stop
if [ -e /etc/init.d/postgres ]; then
[ ! -e /run/openrc/started/postgres ] && service postgres start && STOP_POSTGRES=1
echo 'DROP DATABASE opendatakitbuild; DROP ROLE opendatakitbuild;' | lxc-attach -u 5432 -g 5432 postgres -- psql
[ ! -z ${STOP_POSTGRES} ] && service postgres stop
fi
exit 0

View File

@ -7,8 +7,10 @@ rm -f /etc/init.d/opendatakit
rc-update -u
# Drop database and user
[ ! -e /run/openrc/started/postgres ] && service postgres start && STOP_POSTGRES=1
echo 'DROP DATABASE opendatakit; DROP ROLE opendatakit;' | lxc-attach -u 5432 -g 5432 postgres -- psql
[ ! -z ${STOP_POSTGRES} ] && service postgres stop
if [ -e /etc/init.d/postgres ]; then
[ ! -e /run/openrc/started/postgres ] && service postgres start && STOP_POSTGRES=1
echo 'DROP DATABASE opendatakit; DROP ROLE opendatakit;' | lxc-attach -u 5432 -g 5432 postgres -- psql
[ ! -z ${STOP_POSTGRES} ] && service postgres stop
fi
exit 0

View File

@ -7,8 +7,10 @@ rm -f /etc/init.d/openmapkit
rc-update -u
# Drop database and user
[ ! -e /run/openrc/started/postgres ] && service postgres start && STOP_POSTGRES=1
echo 'DROP DATABASE openmapkit; DROP ROLE openmapkit;' | lxc-attach -u 5432 -g 5432 postgres -- psql
[ ! -z ${STOP_POSTGRES} ] && service postgres stop
if [ -e /etc/init.d/postgres ]; then
[ ! -e /run/openrc/started/postgres ] && service postgres start && STOP_POSTGRES=1
echo 'DROP DATABASE openmapkit; DROP ROLE openmapkit;' | lxc-attach -u 5432 -g 5432 postgres -- psql
[ ! -z ${STOP_POSTGRES} ] && service postgres stop
fi
exit 0

View File

@ -7,14 +7,18 @@ rm -f /etc/init.d/pandora
rc-update -u
# Drop database and user
[ ! -e /run/openrc/started/postgres ] && service postgres start && STOP_POSTGRES=1
echo 'DROP DATABASE pandora; DROP ROLE pandora;' | lxc-attach -u 5432 -g 5432 postgres -- psql
[ ! -z ${STOP_POSTGRES} ] && service postgres stop
if [ -e /etc/init.d/postgres ]; then
[ ! -e /run/openrc/started/postgres ] && service postgres start && STOP_POSTGRES=1
echo 'DROP DATABASE pandora; DROP ROLE pandora;' | lxc-attach -u 5432 -g 5432 postgres -- psql
[ ! -z ${STOP_POSTGRES} ] && service postgres stop
fi
# Remove RabbitMQ vhost and user
[ ! -e /run/openrc/started/rabbitmq ] && service rabbitmq start && STOP_RABBITMQ=1
lxc-attach rabbitmq -- rabbitmqctl delete_vhost /pandora || true
lxc-attach rabbitmq -- rabbitmqctl delete_user pandora || true
[ ! -z ${STOP_RABBITMQ} ] && service rabbitmq stop
if [ -e /etc/init.d/rabbitmq ]; then
[ ! -e /run/openrc/started/rabbitmq ] && service rabbitmq start && STOP_RABBITMQ=1
lxc-attach rabbitmq -- rabbitmqctl delete_vhost /pandora || true
lxc-attach rabbitmq -- rabbitmqctl delete_user pandora || true
[ ! -z ${STOP_RABBITMQ} ] && service rabbitmq stop
fi
exit 0

View File

@ -7,8 +7,10 @@ rm -f /etc/init.d/sahana-demo
rc-update -u
# Drop database and user
[ ! -e /run/openrc/started/postgres ] && service postgres start && STOP_POSTGRES=1
echo 'DROP DATABASE sahanademo; DROP ROLE sahanademo;' | lxc-attach -u 5432 -g 5432 postgres -- psql
[ ! -z ${STOP_POSTGRES} ] && service postgres stop
if [ -e /etc/init.d/postgres ]; then
[ ! -e /run/openrc/started/postgres ] && service postgres start && STOP_POSTGRES=1
echo 'DROP DATABASE sahanademo; DROP ROLE sahanademo;' | lxc-attach -u 5432 -g 5432 postgres -- psql
[ ! -z ${STOP_POSTGRES} ] && service postgres stop
fi
exit 0

View File

@ -7,8 +7,10 @@ rm -f /etc/init.d/sahana
rc-update -u
# Drop database and user
[ ! -e /run/openrc/started/postgres ] && service postgres start && STOP_POSTGRES=1
echo 'DROP DATABASE sahana; DROP ROLE sahana;' | lxc-attach -u 5432 -g 5432 postgres -- psql
[ ! -z ${STOP_POSTGRES} ] && service postgres stop
if [ -e /etc/init.d/postgres ]; then
[ ! -e /run/openrc/started/postgres ] && service postgres start && STOP_POSTGRES=1
echo 'DROP DATABASE sahana; DROP ROLE sahana;' | lxc-attach -u 5432 -g 5432 postgres -- psql
[ ! -z ${STOP_POSTGRES} ] && service postgres stop
fi
exit 0

View File

@ -7,8 +7,10 @@ rm -f /etc/init.d/sambro
rc-update -u
# Drop database and user
[ ! -e /run/openrc/started/postgres ] && service postgres start && STOP_POSTGRES=1
echo 'DROP DATABASE sambro; DROP ROLE sambro;' | lxc-attach -u 5432 -g 5432 postgres -- psql
[ ! -z ${STOP_POSTGRES} ] && service postgres stop
if [ -e /etc/init.d/postgres ]; then
[ ! -e /run/openrc/started/postgres ] && service postgres start && STOP_POSTGRES=1
echo 'DROP DATABASE sambro; DROP ROLE sambro;' | lxc-attach -u 5432 -g 5432 postgres -- psql
[ ! -z ${STOP_POSTGRES} ] && service postgres stop
fi
exit 0

View File

@ -10,8 +10,10 @@ rm -f /etc/init.d/seeddms
rc-update -u
# Drop database and user
[ ! -e /run/openrc/started/postgres ] && service postgres start && STOP_POSTGRES=1
echo 'DROP DATABASE seeddms; DROP ROLE seeddms;' | lxc-attach -u 5432 -g 5432 postgres -- psql
[ ! -z ${STOP_POSTGRES} ] && service postgres stop
if [ -e /etc/init.d/postgres ]; then
[ ! -e /run/openrc/started/postgres ] && service postgres start && STOP_POSTGRES=1
echo 'DROP DATABASE seeddms; DROP ROLE seeddms;' | lxc-attach -u 5432 -g 5432 postgres -- psql
[ ! -z ${STOP_POSTGRES} ] && service postgres stop
fi
exit 0

View File

@ -7,8 +7,10 @@ rm -f /etc/init.d/sigmah
rc-update -u
# Drop database and user
[ ! -e /run/openrc/started/postgres ] && service postgres start && STOP_POSTGRES=1
echo 'DROP DATABASE sigmah; DROP ROLE sigmah;' | lxc-attach -u 5432 -g 5432 postgres -- psql
[ ! -z ${STOP_POSTGRES} ] && service postgres stop
if [ -e /etc/init.d/postgres ]; then
[ ! -e /run/openrc/started/postgres ] && service postgres start && STOP_POSTGRES=1
echo 'DROP DATABASE sigmah; DROP ROLE sigmah;' | lxc-attach -u 5432 -g 5432 postgres -- psql
[ ! -z ${STOP_POSTGRES} ] && service postgres stop
fi
exit 0

View File

@ -10,8 +10,10 @@ rm -f /etc/init.d/ushahidi
rc-update -u
# Drop database and user
[ ! -e /run/openrc/started/mariadb ] && service mariadb start && STOP_MARIADB=1
echo 'DROP DATABASE ushahidi; DROP USER ushahidi;' | lxc-attach mariadb -- mysql
[ ! -z ${STOP_MARIADB} ] && service mariadb stop
if [ -e /etc/init.d/mariadb ]; then
[ ! -e /run/openrc/started/mariadb ] && service mariadb start && STOP_MARIADB=1
echo 'DROP DATABASE ushahidi; DROP USER ushahidi;' | lxc-attach mariadb -- mysql
[ ! -z ${STOP_MARIADB} ] && service mariadb stop
fi
exit 0