OSDN Git Service

Created rcscript for sslproxy
authorShinya TAKEBAYASHI <makoto@kanon-net.jp>
Tue, 1 Sep 2009 12:03:24 +0000 (21:03 +0900)
committerShinya TAKEBAYASHI <makoto@kanon-net.jp>
Tue, 1 Sep 2009 12:03:24 +0000 (21:03 +0900)
init.d/sslproxyd [new file with mode: 0755]

diff --git a/init.d/sslproxyd b/init.d/sslproxyd
new file mode 100755 (executable)
index 0000000..b1b31f8
--- /dev/null
@@ -0,0 +1,173 @@
+#!/bin/sh
+# Start/Stop script for sslproxy
+#
+# chkconfig: - 99 01
+# description: Start and stop sslproxy
+#
+# processname: sslproxy
+#
+# Author: Shinya TAKEBAYASHI
+# Released: September 2009
+# Licence: GNU General Public Licence
+
+
+PROG="sslproxy"
+DAEMON="/usr/sbin/sslproxyadm"
+LOCKFILE="/var/lock/subsys/sslproxy"
+
+start() {
+    if [ -e $LOCKFILE ]; then
+       echo "$PROG is running"
+       return
+    fi
+
+    echo -n "Starting $PROG: "
+    $DAEMON start
+    RETVAL=$?
+
+    if [ $RETVAL -ne 0 ]; then
+       echo "error occured"
+       echo "$PROG was not started"
+    else
+       echo "done"
+       touch $LOCKFILE
+    fi
+
+    return $RETVAL
+}
+
+stop() {
+    echo -n "Stopping $PROG: "
+    $DAEMON stop
+    RETVAL=$?
+
+    if [ $RETVAL -eq 0 ]; then
+       echo "done"
+       cleanup
+    fi
+
+    return $RETVAL
+}
+
+restart() {
+    echo -n "Restarting $PROG process: "
+    $DAEMON restart
+    RETVAL=$?
+
+    if [ $RETVAL -eq 0 ]; then
+       echo "done"
+    else
+       echo "error"
+    fi
+
+    return $RETVAL
+}
+
+status() {
+    $DAEMON status
+    RETVAL=$?
+
+    return $RETVAL
+}
+
+reload() {
+    echo -n "Reloading $DAEMON process: "
+    $DAEMON reload
+    RETVAL=$?
+
+    if [ $RETVAL -eq 0 ]; then
+       echo "done"
+    else
+       echo "error"
+    fi
+
+    return $RETVAL
+}
+
+check() {
+    echo -n "Checking target status: "
+    $DAEMON check
+    RETVAL=$?
+
+    if [ $RETVAL -eq 0 ]; then
+       echo "OK"
+    else
+       echo "NG"
+    fi
+
+    return $RETVAL
+}
+
+config() {
+    echo -n "Checking configuration file: "
+    $DAEMON config
+    RETVAL=$?
+
+    if [ $RETVAL -eq 0 ]; then
+       echo "OK"
+    else
+       echo "ERROR"
+    fi
+
+    return $RETVAL
+}
+
+cleanup() {
+       rm -rf $LOCKFILE
+}
+
+
+# Prefer for Running script
+if [ ! -x $DAEMON ]; then
+    echo "$DAEMON does not exist!"
+    exit -1
+fi
+
+# Privilege check
+
+if [ `id -u` -ne '0' ]; then
+    echo "This script must run as root."
+    exit -1
+fi
+
+case "$1" in
+    start)
+       start
+       ;;
+
+    stop)
+       stop
+       ;;
+
+    restart)
+       restart
+       ;;
+
+    reload)
+       reload
+       ;;
+
+    check)
+       check
+       ;;
+
+    status)
+       status
+       ;;
+
+    config)
+       config
+       ;;
+
+    condrestart)
+       stop
+       sleep 1
+       start
+       ;;
+
+    *)
+       echo "Usage: $0 {start|stop|restart|reload|check|status|config|condrestart}"
+       RETVAL=-1
+esac
+
+exit $RETVAL