#!/bin/sh # # 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 2 # 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. # Strictness to avoid folly set -e set -u prefix=@prefix@ exec_prefix=@exec_prefix@ OPT_ACTION="" OPT_CONFIG="" OPT_PID_DIR="" OSRF_HOSTNAME="" # --------------------------------------------------------------------------- # Make sure we're running as the correct user # --------------------------------------------------------------------------- [ $(whoami) != 'opensrf' ] && echo 'Must run as user "opensrf"' && exit; usage() { cat << EOF usage: $0 [OPTION]... -c -a Mandatory parameters: -a action to perform Optional parameters:"; -c full path to C configuration file (opensrf_core.xml) -d store PID files in this directory -l accept 'localhost' as the fully-qualified domain name Actions include: stop_all start_all restart_all Examples: $0 -a restart_all $0 -l -c opensrf_core.xml -a restart_all EOF } # --------------------------------------------------------------------------- # Load the command line options and set the global vars # --------------------------------------------------------------------------- while getopts "a:d:c:s:k:lh" flag; do case $flag in "a") OPT_ACTION="$OPTARG";; "c") OPT_CONFIG="$OPTARG";; "d") OPT_PID_DIR="$OPTARG";; "l") export OSRF_HOSTNAME="localhost";; "h"|*) usage;; esac; done OSRF_CONFIG="@bindir@/osrf_config" [ ! -f "$OSRF_CONFIG" ] && OSRF_CONFIG=`which osrf_config` [ -z "$OPT_CONFIG" ] && OPT_CONFIG=`$OSRF_CONFIG --sysconfdir`/opensrf_core.xml; if [ ! -r "$OPT_CONFIG" ]; then echo "Please specify the location of the opensrf_core.xml file using the -c flag"; exit 1; fi; [ -z "$OPT_PID_DIR" ] && OPT_PID_DIR=`$OSRF_CONFIG --localstatedir`/run/opensrf; [ -z "$OPT_ACTION" ] && usage; start_all() { opensrf-perl.pl --pid-dir $OPT_PID_DIR \ --config $OPT_CONFIG --start-all --settings-startup-pause 3 } stop_all() { opensrf-perl.pl --pid-dir $OPT_PID_DIR --config $OPT_CONFIG --stop-all } # --------------------------------------------------------------------------- # Do the requested action # --------------------------------------------------------------------------- echo "$0 is deprecated. Use osrf_control instead" case $OPT_ACTION in "stop_all") stop_all;; "start_all") start_all;; "restart_all") stop_all; start_all;; *) usage;; esac;