From b7aedad58925fcbbd60a47d43e05c95bbaaf3d11 Mon Sep 17 00:00:00 2001 From: Disassembler Date: Thu, 13 Sep 2018 20:42:11 +0200 Subject: [PATCH] start/stop prepreqs --- ckan/setup.sh | 13 ++++++------- crisiscleanup/setup.sh | 9 ++------- cts/setup.sh | 9 ++------- gnuhealth/setup.sh | 11 +++-------- setup-all.sh | 6 +++--- 5 files changed, 16 insertions(+), 32 deletions(-) diff --git a/ckan/setup.sh b/ckan/setup.sh index 249b269..fd222d5 100755 --- a/ckan/setup.sh +++ b/ckan/setup.sh @@ -4,10 +4,9 @@ set -e SOURCE_DIR=$(realpath $(dirname "${0}"))/setup # Check prerequisites -# TODO: Have setup prereqs in a manifest file -for SERVICE in postgres redis solr; do - [ ! -e /run/openrc/started/${SERVICE} ] && service ${SERVICE} start && STOP_SERVICES="${STOP_SERVICES} ${SERVICE}" -done +[ ! -e /run/openrc/started/postgres ] && service postgres start && STOP_POSTGRES=1 +[ ! -e /run/openrc/started/redis ] && service redis start && STOP_REDIS=1 +[ ! -e /run/openrc/started/solr ] && service solr start && STOP_SOLR=1 # Create database export CKAN_PWD=$(head -c 18 /dev/urandom | base64) @@ -57,6 +56,6 @@ cp ${SOURCE_DIR}/etc/init.d/ckan /etc/init.d/ckan rc-update -u # Stop services required for setup -for SERVICE in ${STOP_SERVICES}; do - service ${SERVICE} stop -done +[ ! -z ${STOP_POSTGRES} ] && service postgres stop +[ ! -z ${STOP_REDIS} ] && service redis stop +[ ! -z ${STOP_SOLR} ] && service solr stop diff --git a/crisiscleanup/setup.sh b/crisiscleanup/setup.sh index 8e5a218..9fb529e 100644 --- a/crisiscleanup/setup.sh +++ b/crisiscleanup/setup.sh @@ -4,10 +4,7 @@ set -e SOURCE_DIR=$(realpath $(dirname "${0}"))/setup # Check prerequisites -# TODO: Have setup prereqs in a manifest file -for SERVICE in postgres; do - [ ! -e /run/openrc/started/${SERVICE} ] && service ${SERVICE} start && STOP_SERVICES="${STOP_SERVICES} ${SERVICE}" -done +[ ! -e /run/openrc/started/postgres ] && service postgres start && STOP_POSTGRES=1 # Create database export CRISISCLEANUP_PWD=$(head -c 18 /dev/urandom | base64) @@ -39,6 +36,4 @@ cp ${SOURCE_DIR}/etc/init.d/crisiscleanup /etc/init.d/crisiscleanup rc-update -u # Stop services required for setup -for SERVICE in ${STOP_SERVICES}; do - service ${SERVICE} stop -done +[ ! -z ${STOP_POSTGRES} ] && service postgres stop diff --git a/cts/setup.sh b/cts/setup.sh index 7b514cf..0e28ae6 100755 --- a/cts/setup.sh +++ b/cts/setup.sh @@ -4,10 +4,7 @@ set -e SOURCE_DIR=$(realpath $(dirname "${0}"))/setup # Check prerequisites -# TODO: Have setup prereqs in a manifest file -for SERVICE in postgres; do - [ ! -e /run/openrc/started/${SERVICE} ] && service ${SERVICE} start && STOP_SERVICES="${STOP_SERVICES} ${SERVICE}" -done +[ ! -e /run/openrc/started/postgres ] && service postgres start && STOP_POSTGRES=1 # Create database export CTS_PWD=$(head -c 18 /dev/urandom | base64) @@ -43,6 +40,4 @@ cp ${SOURCE_DIR}/etc/init.d/cts /etc/init.d/cts rc-update -u # Stop services required for setup -for SERVICE in ${STOP_SERVICES}; do - service ${SERVICE} stop -done +[ ! -z ${STOP_POSTGRES} ] && service postgres stop diff --git a/gnuhealth/setup.sh b/gnuhealth/setup.sh index 6c7061d..21e5eb8 100755 --- a/gnuhealth/setup.sh +++ b/gnuhealth/setup.sh @@ -4,10 +4,7 @@ set -e SOURCE_DIR=$(realpath $(dirname "${0}"))/setup # Check prerequisites -# TODO: Have setup prereqs in a manifest file -for SERVICE in postgres; do - [ ! -e /run/openrc/started/${SERVICE} ] && service ${SERVICE} start && STOP_SERVICES="${STOP_SERVICES} ${SERVICE}" -done +[ ! -e /run/openrc/started/postgres ] && service postgres start && STOP_POSTGRES=1 # Create databases export GNUHEALTH_PWD=$(head -c 18 /dev/urandom | base64 | tr -d '/+=') @@ -27,7 +24,7 @@ vmmgr update-login gnuhealth "${GNUHEALTH_ADMIN_USER}" "${GNUHEALTH_ADMIN_PWD}" # Populate demo database wget http://health.gnu.org/downloads/postgres_dumps/gnuhealth-32-demo.sql.gz -O /tmp/gnuhealth_demo.sql.gz -zcat /tmp/gnuhealth_demo.sql.gz | lxc-attach -u 5432 -g 5432 postgres -- sh -c 'PGPASSWORD=${GNUHEALTH_PWD} psql gnuhealth_demo gnuhealth' +zcat /tmp/gnuhealth_demo.sql.gz | lxc-attach -u 5432 -g 5432 postgres -- sh -c "PGPASSWORD=${GNUHEALTH_PWD} psql gnuhealth_demo gnuhealth" rm -f /tmp/gnuhealth_demo.sql.gz # Install service @@ -35,6 +32,4 @@ cp ${SOURCE_DIR}/etc/init.d/gnuhealth /etc/init.d/gnuhealth rc-update -u # Stop services required for setup -for SERVICE in ${STOP_SERVICES}; do - service ${SERVICE} stop -done +[ ! -z ${STOP_POSTGRES} ] && service postgres stop diff --git a/setup-all.sh b/setup-all.sh index 0064dea..4fe81e2 100755 --- a/setup-all.sh +++ b/setup-all.sh @@ -16,9 +16,9 @@ ${SOURCE_DIR}/solr/setup.sh ${SOURCE_DIR}/ckan/setup.sh ${SOURCE_DIR}/crisiscleanup/setup.sh ${SOURCE_DIR}/cts/setup.sh -#${SOURCE_DIR}/frontlinesms/setup.sh -#${SOURCE_DIR}/gnuhealth/setup.sh -#${SOURCE_DIR}/kanboard/setup.sh +${SOURCE_DIR}/frontlinesms/setup.sh +${SOURCE_DIR}/gnuhealth/setup.sh +${SOURCE_DIR}/kanboard/setup.sh #${SOURCE_DIR}/opendatakit/setup.sh #${SOURCE_DIR}/opendatakit-build/setup.sh #${SOURCE_DIR}/openmapkit/setup.sh