# (c) Copyright 2013 Georgia Public Library Service
# Chris Sharp <csharp@georgialibraries.org
#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program. If not, see <http://www.gnu.org/licenses/>.
-#
# 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
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)
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
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