From 30bd3eb118d37cb1faeb808d4ee182693a4c4c6d Mon Sep 17 00:00:00 2001 From: Chris Sharp Date: Sun, 31 Mar 2013 18:24:51 -0400 Subject: [PATCH] adding some checks to the "switcheroo" script --- switcheroo.sh | 28 ++++++++++++---------------- 1 file changed, 12 insertions(+), 16 deletions(-) diff --git a/switcheroo.sh b/switcheroo.sh index e0feffc..c124752 100755 --- a/switcheroo.sh +++ b/switcheroo.sh @@ -3,19 +3,6 @@ # (c) Copyright 2013 Georgia Public Library Service # Chris Sharp . -# # A utility to ease database server administration by reconfiguring # which database is used for reports queries. It assumes that you're # running pgpool to balance the load between two servers named db02 and @@ -34,6 +21,15 @@ OPENSRF_RESTART="/etc/init.d/opensrf restart" REPORTER_LOCK="/tmp/reporter-LOCK" REPORTS_CMD="/openils/bin/clark-kent.pl" +CheckConfig () { +for FILE in $PGPOOL_CONFIG $DB02_CONFIG $DB03_CONFIG; do +if [ ! -e $FILE ]; then + echo "Required file $FILE is missing. Please create it before running this script again." + exit; +fi; +done +} + GetState () { if [ -e $STATE_FILE ]; then STATE=$(cat $STATE_FILE) @@ -56,14 +52,14 @@ StartReporter () { echo "Attempting to start the reporting process..." su - opensrf -c /bin/bash -c "$REPORTS_CMD -d -c $REPORTS_COUNT" if [ "$(pidof 'Clark Kent, waiting for trouble')" ]; then - echo "Reporting process started successfully." + echo "Reporting process appears to have started successfully." else echo "Looks like something went wrong. Please start the reporter process manually." exit; fi } - +CheckConfig CheckReporter echo "This utility changes which database servers are used to run reports queries." echo @@ -96,7 +92,7 @@ elif [ $CHOICE = "2" ]; then elif [ $CHOICE = "3" ]; then echo "Selecting db03 configuration..." cp -v $DB03_CONFIG $RUNNING_CONFIG - REPORTS_COUNT="12" + REPORTS_COUNT="8" echo "Restarting services to activate new configuration..." $OPENSRF_RESTART StartReporter -- 2.11.0