From 905f2c62c1206d63f3ad36f829d25d72f2c73cb5 Mon Sep 17 00:00:00 2001 From: Disassembler Date: Wed, 31 Oct 2018 09:55:46 +0100 Subject: [PATCH] Drop DB object only if they exist --- ckan/uninstall.sh | 2 +- crisiscleanup/uninstall.sh | 2 +- gnuhealth/uninstall.sh | 2 +- kanboard/uninstall.sh | 2 +- mariadb/install/adminpwd.sql | 2 +- mifosx/uninstall.sh | 2 +- motech/uninstall.sh | 2 +- opendatakit-build/uninstall.sh | 2 +- opendatakit/uninstall.sh | 2 +- openmapkit/uninstall.sh | 2 +- pandora/uninstall.sh | 2 +- sahana-demo/uninstall.sh | 2 +- sahana/uninstall.sh | 2 +- sambro/uninstall.sh | 2 +- seeddms/uninstall.sh | 2 +- sigmah/uninstall.sh | 2 +- ushahidi/uninstall.sh | 2 +- 17 files changed, 17 insertions(+), 17 deletions(-) diff --git a/ckan/uninstall.sh b/ckan/uninstall.sh index 7db5212..78c36d0 100755 --- a/ckan/uninstall.sh +++ b/ckan/uninstall.sh @@ -11,7 +11,7 @@ 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 +echo 'DROP DATABASE IF EXISTS ckan; DROP DATABASE IF EXISTS ckan_datastore; DROP ROLE IF EXISTS ckan; DROP ROLE IF EXISTS ckan_datastore;' | lxc-attach -u 5432 -g 5432 postgres -- psql [ ! -z ${STOP_POSTGRES} ] && service postgres stop # Remove redis data diff --git a/crisiscleanup/uninstall.sh b/crisiscleanup/uninstall.sh index 19c990a..704bae2 100755 --- a/crisiscleanup/uninstall.sh +++ b/crisiscleanup/uninstall.sh @@ -8,7 +8,7 @@ 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 +echo 'DROP DATABASE IF EXISTS crisiscleanup; DROP ROLE IF EXISTS crisiscleanup;' | lxc-attach -u 5432 -g 5432 postgres -- psql [ ! -z ${STOP_POSTGRES} ] && service postgres stop exit 0 diff --git a/gnuhealth/uninstall.sh b/gnuhealth/uninstall.sh index 5655cd8..b737e58 100755 --- a/gnuhealth/uninstall.sh +++ b/gnuhealth/uninstall.sh @@ -8,7 +8,7 @@ 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 +echo 'DROP DATABASE IF EXISTS gnuhealth; DROP DATABASE IF EXISTS gnuhealth_demo; DROP ROLE IF EXISTS gnuhealth;' | lxc-attach -u 5432 -g 5432 postgres -- psql [ ! -z ${STOP_POSTGRES} ] && service postgres stop exit 0 diff --git a/kanboard/uninstall.sh b/kanboard/uninstall.sh index 3cd36c2..847a64f 100755 --- a/kanboard/uninstall.sh +++ b/kanboard/uninstall.sh @@ -11,7 +11,7 @@ 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 +echo 'DROP DATABASE IF EXISTS kanboard; DROP ROLE IF EXISTS kanboard;' | lxc-attach -u 5432 -g 5432 postgres -- psql [ ! -z ${STOP_POSTGRES} ] && service postgres stop exit 0 diff --git a/mariadb/install/adminpwd.sql b/mariadb/install/adminpwd.sql index c96e6fd..a33a272 100644 --- a/mariadb/install/adminpwd.sql +++ b/mariadb/install/adminpwd.sql @@ -2,4 +2,4 @@ DELETE FROM mysql.user WHERE User != 'root' OR Host != 'localhost'; INSTALL PLUGIN unix_socket SONAME 'auth_socket'; UPDATE mysql.user SET plugin='unix_socket'; FLUSH PRIVILEGES; -DROP DATABASE test; +DROP DATABASE IF EXISTS test; diff --git a/mifosx/uninstall.sh b/mifosx/uninstall.sh index 84fef6c..bf68ad2 100755 --- a/mifosx/uninstall.sh +++ b/mifosx/uninstall.sh @@ -8,7 +8,7 @@ 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 +echo 'DROP DATABASE IF EXISTS `mifosplatform-tenants`; DROP DATABASE IF EXISTS `mifostenant-default`; DROP USER IF EXISTS `mifosx`;' | lxc-attach mariadb -- mysql [ ! -z ${STOP_MARIADB} ] && service mariadb stop exit 0 diff --git a/motech/uninstall.sh b/motech/uninstall.sh index 96017ca..af9f22a 100755 --- a/motech/uninstall.sh +++ b/motech/uninstall.sh @@ -8,7 +8,7 @@ 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 +echo 'DROP DATABASE IF EXISTS motech; DROP DATABASE IF EXISTS motechdata; DROP DATABASE IF EXISTS motechquartz; DROP DATABASE IF EXISTS motechschema; DROP ROLE IF EXISTS motech;' | lxc-attach -u 5432 -g 5432 postgres -- psql [ ! -z ${STOP_POSTGRES} ] && service postgres stop # TODO: Clear ActiveMQ config diff --git a/opendatakit-build/uninstall.sh b/opendatakit-build/uninstall.sh index 8447063..96da8c1 100755 --- a/opendatakit-build/uninstall.sh +++ b/opendatakit-build/uninstall.sh @@ -8,7 +8,7 @@ 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 +echo 'DROP DATABASE IF EXISTS opendatakitbuild; DROP ROLE IF EXISTS opendatakitbuild;' | lxc-attach -u 5432 -g 5432 postgres -- psql [ ! -z ${STOP_POSTGRES} ] && service postgres stop exit 0 diff --git a/opendatakit/uninstall.sh b/opendatakit/uninstall.sh index c6dea64..f98fe47 100755 --- a/opendatakit/uninstall.sh +++ b/opendatakit/uninstall.sh @@ -8,7 +8,7 @@ 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 +echo 'DROP DATABASE IF EXISTS opendatakit; DROP ROLE IF EXISTS opendatakit;' | lxc-attach -u 5432 -g 5432 postgres -- psql [ ! -z ${STOP_POSTGRES} ] && service postgres stop exit 0 diff --git a/openmapkit/uninstall.sh b/openmapkit/uninstall.sh index 9bb73da..d082623 100755 --- a/openmapkit/uninstall.sh +++ b/openmapkit/uninstall.sh @@ -8,7 +8,7 @@ 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 +echo 'DROP DATABASE IF EXISTS openmapkit; DROP ROLE IF EXISTS openmapkit;' | lxc-attach -u 5432 -g 5432 postgres -- psql [ ! -z ${STOP_POSTGRES} ] && service postgres stop exit 0 diff --git a/pandora/uninstall.sh b/pandora/uninstall.sh index 8fbdeca..0f43dea 100755 --- a/pandora/uninstall.sh +++ b/pandora/uninstall.sh @@ -8,7 +8,7 @@ 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 +echo 'DROP DATABASE IF EXISTS pandora; DROP ROLE IF EXISTS pandora;' | lxc-attach -u 5432 -g 5432 postgres -- psql [ ! -z ${STOP_POSTGRES} ] && service postgres stop # Remove RabbitMQ vhost and user diff --git a/sahana-demo/uninstall.sh b/sahana-demo/uninstall.sh index 9c70ccd..d5b12aa 100755 --- a/sahana-demo/uninstall.sh +++ b/sahana-demo/uninstall.sh @@ -8,7 +8,7 @@ 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 +echo 'DROP DATABASE IF EXISTS sahanademo; DROP ROLE IF EXISTS sahanademo;' | lxc-attach -u 5432 -g 5432 postgres -- psql [ ! -z ${STOP_POSTGRES} ] && service postgres stop exit 0 diff --git a/sahana/uninstall.sh b/sahana/uninstall.sh index 2e281e4..7667fd8 100755 --- a/sahana/uninstall.sh +++ b/sahana/uninstall.sh @@ -8,7 +8,7 @@ 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 +echo 'DROP DATABASE IF EXISTS sahana; DROP ROLE IF EXISTS sahana;' | lxc-attach -u 5432 -g 5432 postgres -- psql [ ! -z ${STOP_POSTGRES} ] && service postgres stop exit 0 diff --git a/sambro/uninstall.sh b/sambro/uninstall.sh index ffcd3fc..8a9aca7 100755 --- a/sambro/uninstall.sh +++ b/sambro/uninstall.sh @@ -8,7 +8,7 @@ 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 +echo 'DROP DATABASE IF EXISTS sambro; DROP ROLE IF EXISTS sambro;' | lxc-attach -u 5432 -g 5432 postgres -- psql [ ! -z ${STOP_POSTGRES} ] && service postgres stop exit 0 diff --git a/seeddms/uninstall.sh b/seeddms/uninstall.sh index 25d487b..a1a47ef 100755 --- a/seeddms/uninstall.sh +++ b/seeddms/uninstall.sh @@ -11,7 +11,7 @@ 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 +echo 'DROP DATABASE IF EXISTS seeddms; DROP ROLE IF EXISTS seeddms;' | lxc-attach -u 5432 -g 5432 postgres -- psql [ ! -z ${STOP_POSTGRES} ] && service postgres stop exit 0 diff --git a/sigmah/uninstall.sh b/sigmah/uninstall.sh index ada1474..81f0e63 100755 --- a/sigmah/uninstall.sh +++ b/sigmah/uninstall.sh @@ -8,7 +8,7 @@ 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 +echo 'DROP DATABASE IF EXISTS sigmah; DROP ROLE IF EXISTS sigmah;' | lxc-attach -u 5432 -g 5432 postgres -- psql [ ! -z ${STOP_POSTGRES} ] && service postgres stop exit 0 diff --git a/ushahidi/uninstall.sh b/ushahidi/uninstall.sh index 4403b34..d4b2d26 100755 --- a/ushahidi/uninstall.sh +++ b/ushahidi/uninstall.sh @@ -11,7 +11,7 @@ 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 +echo 'DROP DATABASE IF EXISTS ushahidi; DROP USER IF EXISTS ushahidi;' | lxc-attach mariadb -- mysql [ ! -z ${STOP_MARIADB} ] && service mariadb stop exit 0