Browse Source

Thomas Bj�rklund's start|stop checked in

Jiri Kuthan 22 years ago
parent
commit
d84c7efa44
1 changed files with 66 additions and 1 deletions
  1. 66 1
      scripts/sc

+ 66 - 1
scripts/sc

@@ -4,6 +4,14 @@
 #
 # sc: ser control; tool for maintaining ser's databases
 #
+# History:
+# --------
+# 2003-02-23 Thomas's start|stop commands checked in
+
+# configuration for starting/stopping ser
+PID_FILE=/var/run/ser.pid
+SYSLOG=1 # 0=output to console, 1=output to syslog
+STARTOPTIONS= # for example -dddd
 
 # ser's FIFO server
 if [ -z "$SER_FIFO" ]; then
@@ -464,9 +472,11 @@ credentials()
 #================================================================
 
 if [ -z "$SIP_DOMAIN" ] ; then
+	echo
 	echo "You need to set environment variable SIP_DOMAIN (e.g. to 'foobar.com') first"
 	echo
-	usage
+#	This confuses new users cause its easy to miss the information above
+#	usage
 	exit 1
 fi
 
@@ -475,6 +485,61 @@ export PW
 
 case $1 in
 
+	start)
+		echo -n "Starting SER : "
+		if [ -r $PID_FILE ] ; then
+			echo "PID file exists! ($PID_FILE) already running?"
+			exit 1
+		else
+			if [ $SYSLOG = 1 ] ; then
+				ser -P $PID_FILE $STARTOPTIONS 1>/dev/null 2>/dev/null
+			else
+				ser -P $PID_FILE $STARTOPTIONS
+			fi
+			sleep 1
+			echo "started pid(`cat $PID_FILE`)"
+		fi
+		exit 0
+	;;
+
+	stop)
+		echo -n "Stopping SER : "
+		if [ -r $PID_FILE ] ; then
+			kill `cat $PID_FILE`
+			echo "stopped"
+		else
+			echo No PID file found!
+			exit 1
+		fi
+		exit 0
+	;;
+
+	restart)
+		echo -n "Stopping SER : "
+		if [ -r $PID_FILE ] ; then
+			kill `cat $PID_FILE`
+			echo "stopped"
+		else
+			echo No PID file found! SER problably not running
+			exit 1
+		fi
+		sleep 2
+		echo -n "Starting SER : "
+		if [ -r $PID_FILE ] ; then
+			echo "PID file exists! ($PID_FILE) already running?"
+			exit 1
+		else
+			if [ $SYSLOG = 1 ] ; then
+				ser -P $PID_FILE $STARTOPTIONS 1>/dev/null 2>/dev/null
+			else
+				ser -P $PID_FILE $STARTOPTIONS
+			fi
+			sleep 1
+			echo "started pid(`cat $PID_FILE`)"
+		fi
+		exit 0
+	;;
+
 	passwd)
 		if [ $# -ne 3 ] ; then
 			usage