[Opensrf-commits] r1250 - trunk/bin

svn at svn.open-ils.org svn at svn.open-ils.org
Sun Mar 2 23:28:54 EST 2008


Author: dbs
Date: 2008-03-02 22:56:53 -0500 (Sun, 02 Mar 2008)
New Revision: 1250

Modified:
   trunk/bin/osrf_ctl.sh
Log:
Make the path to opensrf_core.xml argument optional, with a default
value based on the path used to invoke osrf_ctl.sh


Modified: trunk/bin/osrf_ctl.sh
===================================================================
--- trunk/bin/osrf_ctl.sh	2008-02-16 18:12:57 UTC (rev 1249)
+++ trunk/bin/osrf_ctl.sh	2008-03-03 03:56:53 UTC (rev 1250)
@@ -16,9 +16,9 @@
 	echo "";
 	echo "Mandatory parameters:";
 	echo -e "  -a\t\taction to perform";
-	echo -e "  -c\t\tfull path to C configuration file (opensrf_core.xml)";
 	echo "";
 	echo "Optional parameters:";
+	echo -e "  -c\t\tfull path to C configuration file (opensrf_core.xml)";
 	echo -e "  -d\t\tstore PID files in this directory";
 	echo -e "  -l\t\taccept 'localhost' as the fully-qualified domain name";
 	echo "";
@@ -40,17 +40,33 @@
 	echo -e "\trestart_all"
 	echo "";
 	echo "Examples:";
-	echo "  $0 -c opensrf_core.xml -a restart_all";
+	echo "  $0 -a restart_all";
 	echo "  $0 -l -c opensrf_core.xml -a restart_all";
 	echo "";
 	exit;
 }
 
+# Get root directory of this script
+function basepath {
+	BASEDIR=""
+	script_path="$1"
+	IFS="/"
+	for p in $script_path
+	do
+		if [ -z "$BASEDIR" ] && [ -n "$p" ]; then
+			BASEDIR="$p"
+		fi;
+	done
+	BASEDIR="/$BASEDIR"
+	IFS=
+}
 
+basepath $0
+
 # ---------------------------------------------------------------------------
 # Load the command line options and set the global vars
 # ---------------------------------------------------------------------------
-while getopts  "c:a:d:lh" flag; do
+while getopts  "a:d:clh" flag; do
 	case $flag in	
 		"a")		OPT_ACTION="$OPTARG";;
 		"c")		OPT_CONFIG="$OPTARG";;
@@ -60,7 +76,7 @@
 	esac;
 done
 
-
+[ -z "$OPT_CONFIG" ] && OPT_CONFIG="$BASEDIR/conf/opensrf_core.xml";
 [ -z "$OPT_PID_DIR" ] && OPT_PID_DIR=/tmp;
 [ -z "$OPT_ACTION" ] && usage;
 



More information about the opensrf-commits mailing list