[init]Vpsmate

By | 2013年5月25日
#!/bin/sh
#
# vpsmate - this script starts and stops the vpsmate daemon
#
# chkconfig:   - 85 15
# description: VPSMate is a web-based linux VPS management tools
# processname: vpsmate
# pidfile:     /var/run/vpsmate.pid

# Source function library.
. /etc/rc.d/init.d/functions

# Source networking configuration.
. /etc/sysconfig/network

# Check that networking is up.
[ "$NETWORKING" = "no" ] && exit 0

exec="/usr/local/vpsmate/server.py"
pidfile="/var/run/vpsmate.pid"

lockfile=/var/lock/subsys/vpsmate

start() {
    [ -x $vpsmate ] || exit 5
    echo -n $"Starting VPSMate: "
    daemon --pidfile="$pidfile" "$exec &"
    retval=$?
    echo
    [ $retval -eq 0 ] && touch $lockfile
    return $retval
}

stop() {
    echo -n $"Stopping VPSMate: "
    killproc -p "$pidfile" $exec
    #killproc $prog -TERM
    retval=$?
    if [ $retval -eq 0 ]; then
        if [ "$CONSOLETYPE" != "serial" ]; then
           echo -en "\\033[16G"
        fi
        while rh_status_q
        do
            sleep 1
            echo -n $"."
        done
        rm -f $lockfile
    fi
    echo
    return $retval
}

restart() {
    stop
    start
}

rh_status() {
    status -p "$pidfile" $exec
    #status $prog
}

rh_status_q() {
    rh_status >/dev/null 2>&1
}

case "$1" in
    start)
        rh_status_q && exit 0
        $1
        ;;
    stop)
        rh_status_q || exit 0
        $1
        ;;
    restart)
        $1
        ;;
    status|status_q)
        rh_$1
        ;;
    condrestart|try-restart)
        rh_status_q || exit 7
        restart
	    ;;
    *)
        echo $"Usage: $0 {start|stop|status|restart}"
        exit 2
esac