#! /bin/sh # ### BEGIN INIT INFO # Provides: gfw.press # Required-Start: $remote_fs $syslog # Required-Stop: $remote_fs $syslog # Default-Start: 2 3 4 5 # Default-Stop: 0 1 6 # Short-Description: Initialize gfw.press server # Description: starts gfw.press ### END INIT INFO PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin" PATTERN="java -Dfile.encoding=utf-8 -Dsun.jnu.encoding=utf-8 -Duser.timezone=Asia/Shanghai" PROGNAME=`basename $0` RETURN_STATUS= export PATH PATTERN PROGNAME RETURN_STATUS do_start(){ do_status cd /usr/local/etc/gfw.press if test $RETURN_STATUS -ne 0 ; then test -x server.sh && ./server.sh echo "Strating $PROGNAME ..." else : fi } do_stop(){ PIDs=`ps aux | grep "$PATTERN" | grep -v grep | awk '{print $2}'` echo "Stopping $PROGNAME ..." if test "x$PIDs" != "x" ; then kill -9 "$PIDs" else echo "$PROGNAME is not running." >&2 fi } do_restart(){ do_stop do_start } do_status(){ if ps aux | grep "$PATTERN" | grep -qv grep ; then echo "$PROGNAME is running." RETURN_STATUS=0 else echo "$PROGNAME is not running." RETURN_STATUS=1 fi } case "$1" in start) do_start ;; stop) do_stop ;; restart) do_restart ;; status) do_status ;; *) echo "Usage: $PROGNAME {start|stop|restart|status}" >&2 ; exit 99 ;; esac exit 0