Revision: 75
Author: solomax...@gmail.com
Date: Tue Feb 12 02:46:43 2013
Log: Auto-start script for red5sip is separated from red5sip.sh; jsvc
dependancy is removed
http://code.google.com/p/red5phone/source/detail?r=75
Added:
/branches/red5sip/red5sip
Modified:
/branches/red5sip/red5sip.sh
=======================================
--- /dev/null
+++ /branches/red5sip/red5sip Tue Feb 12 02:46:43 2013
@@ -0,0 +1,60 @@
+#!/bin/sh
+### BEGIN INIT INFO
+# Provides: red5sip
+# Required-Start: networking
+# Required-Stop:
+# Default-Start: 2 3 4 5
+# Default-Stop: 0 1 6
+### END INIT INFO
+set -e
+DESC="Red5Sip bridge"
+NAME=red5sip
+RED5SIP_HOME=/opt/red5sip
+DAEMON=$RED5SIP_HOME/$NAME.sh
+PIDFILE=/var/run/$NAME.pid
+SCRIPTNAME=/etc/init.d/$NAME
+
+#
+# Function that starts the daemon/service.
+#
+d_start() {
+ start-stop-daemon --start -c nobody --pidfile $PIDFILE --chdir
$RED5SIP_HOME --background --make-pidfile --exec $DAEMON
+}
+#
+# Function that stops the daemon/service.
+#
+d_stop() {
+ start-stop-daemon --stop --quiet --pidfile $PIDFILE --name java
+ rm -f $PIDFILE
+}
+
+d_stop() {
+ start-stop-daemon --stop --quiet --pidfile $PIDFILE --name java
+ rm -f $PIDFILE
+}
+
+case "$1" in
+ start)
+ echo -n "Starting $DESC: $NAME\n"
+ d_start
+# echo ".\n"
+ ;;
+ stop)
+ echo -n "Stopping $DESC: $NAME\n"
+ d_stop
+# echo ".\n"
+ ;;
+ restart|force-reload)
+ echo -n "Restarting $DESC: $NAME\n"
+ d_stop
+ sleep 1
+ d_start
+# echo ".\n"
+ ;;
+ *)
+ echo "Usage: $SCRIPTNAME {start|stop|restart|force-reload}" >&2
+ exit 1
+ ;;
+esac
+exit 0
+
=======================================
--- /branches/red5sip/red5sip.sh Wed Feb 6 23:45:11 2013
+++ /branches/red5sip/red5sip.sh Tue Feb 12 02:46:43 2013
@@ -1,53 +1,16 @@
#!/bin/sh
-### BEGIN INIT INFO
-# Provides: red5sip
-# Required-Start: networking
-# Required-Stop:
-# Default-Start: 2 3 4 5
-# Default-Stop: 0 1 6
-### END INIT INFO
+
+if [ -z "$RED5SIP_HOME" ]; then
+ export RED5SIP_HOME=`pwd`;
+fi
+
JAVA_HOME=$(readlink -f /usr/bin/java | sed "s:bin/java::")
-echo $JAVA_HOME
-INSTALL_DIR=$(pwd)
-LIB_DIR=$INSTALL_DIR/lib
-LOGS_DIR=$INSTALL_DIR/log
-JSVC_ERR=$LOGS_DIR/jsvc_red5sip.err
-PID_FILE=/var/run/red5sip.pid
-SETTINGS_FILE=$INSTALL_DIR/settings.properties
+LIB_DIR=$RED5SIP_HOME/lib
+LOGS_DIR=$RED5SIP_HOME/log
+SETTINGS_FILE=$RED5SIP_HOME/settings.properties
CLASSPATH=$(echo $LIB_DIR/*.jar | sed 's/ /:/g')
-case "$1" in
- start)
- #
- # Start backend
- #
- echo "Starting red5sip service"
- jsvc -pidfile $PID_FILE \
- -home $JAVA_HOME \
- -errfile $JSVC_ERR \
- -Dlogs=$LOGS_DIR \
- -cp $CLASSPATH org.red5.sip.app.Application $SETTINGS_FILE
- ;;
-
-
- stop)
- #
- # Stop red5sip service
- #
- jsvc -stop -pidfile $PID_FILE org.red5.sip.app.Application
- exit $?
- ;;
-
- run)
- #
- # Run red5sip
- #
- $JAVA_HOME/bin/java -Dlogs=$LOGS_DIR -cp $CLASSPATH
org.red5.sip.app.Main $SETTINGS_FILE
- ;;
-
- *)
- echo "Usage red5sip.sh start/stop"
- exit 1;;
-esac
+echo "Starting Red5SIP"
+exec $JAVA_HOME/bin/java -Dlogs=$LOGS_DIR -cp $CLASSPATH
org.red5.sip.app.Main $SETTINGS_FILE