diff --git a/ckan/uninstall.sh b/ckan/uninstall.sh index 7db5212..830b45b 100755 --- a/ckan/uninstall.sh +++ b/ckan/uninstall.sh @@ -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 diff --git a/crisiscleanup/uninstall.sh b/crisiscleanup/uninstall.sh index 19c990a..c7b6a72 100755 --- a/crisiscleanup/uninstall.sh +++ b/crisiscleanup/uninstall.sh @@ -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 diff --git a/cts/uninstall.sh b/cts/uninstall.sh index 5475ba9..8124f0b 100755 --- a/cts/uninstall.sh +++ b/cts/uninstall.sh @@ -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 diff --git a/gnuhealth/uninstall.sh b/gnuhealth/uninstall.sh index 5655cd8..a2e8552 100755 --- a/gnuhealth/uninstall.sh +++ b/gnuhealth/uninstall.sh @@ -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 diff --git a/kanboard/uninstall.sh b/kanboard/uninstall.sh index 3cd36c2..03c3a21 100755 --- a/kanboard/uninstall.sh +++ b/kanboard/uninstall.sh @@ -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 diff --git a/mifosx/uninstall.sh b/mifosx/uninstall.sh index 84fef6c..36d08a5 100755 --- a/mifosx/uninstall.sh +++ b/mifosx/uninstall.sh @@ -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 diff --git a/motech/uninstall.sh b/motech/uninstall.sh index 96017ca..d471ecb 100755 --- a/motech/uninstall.sh +++ b/motech/uninstall.sh @@ -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 diff --git a/opendatakit-build/uninstall.sh b/opendatakit-build/uninstall.sh index 8447063..29997e8 100755 --- a/opendatakit-build/uninstall.sh +++ b/opendatakit-build/uninstall.sh @@ -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 diff --git a/opendatakit/uninstall.sh b/opendatakit/uninstall.sh index c6dea64..9004707 100755 --- a/opendatakit/uninstall.sh +++ b/opendatakit/uninstall.sh @@ -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 diff --git a/openmapkit/uninstall.sh b/openmapkit/uninstall.sh index 9bb73da..f68eee5 100755 --- a/openmapkit/uninstall.sh +++ b/openmapkit/uninstall.sh @@ -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 diff --git a/pandora/uninstall.sh b/pandora/uninstall.sh index 8fbdeca..2443e9a 100755 --- a/pandora/uninstall.sh +++ b/pandora/uninstall.sh @@ -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 diff --git a/sahana-demo/uninstall.sh b/sahana-demo/uninstall.sh index 9c70ccd..6926e2c 100755 --- a/sahana-demo/uninstall.sh +++ b/sahana-demo/uninstall.sh @@ -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 diff --git a/sahana/uninstall.sh b/sahana/uninstall.sh index 2e281e4..98a859f 100755 --- a/sahana/uninstall.sh +++ b/sahana/uninstall.sh @@ -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 diff --git a/sambro/uninstall.sh b/sambro/uninstall.sh index ffcd3fc..121c969 100755 --- a/sambro/uninstall.sh +++ b/sambro/uninstall.sh @@ -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 diff --git a/seeddms/uninstall.sh b/seeddms/uninstall.sh index 25d487b..fbcc680 100755 --- a/seeddms/uninstall.sh +++ b/seeddms/uninstall.sh @@ -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 diff --git a/sigmah/uninstall.sh b/sigmah/uninstall.sh index ada1474..83dbc3d 100755 --- a/sigmah/uninstall.sh +++ b/sigmah/uninstall.sh @@ -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 diff --git a/ushahidi/uninstall.sh b/ushahidi/uninstall.sh index 4403b34..8a59676 100755 --- a/ushahidi/uninstall.sh +++ b/ushahidi/uninstall.sh @@ -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