view rc.d/feed-push @ 2:292896092ee6 draft

chmod +x rc.d/feed-push Signed-off-by: Changaco <changaco ατ changaco δοτ net>
author Changaco <changaco ατ changaco δοτ net>
date Mon, 16 Apr 2012 00:09:37 +0200
parents a68d7feeba88
children b88065b70ecd
line wrap: on
line source

#!/bin/bash

. /etc/rc.conf
. /etc/rc.d/functions

get_pid() {
    pgrep -f $daemon_name | grep -v $$
}
PID=$(get_pid)

daemon_bin="/usr/bin/feed-push"
daemon_name=$(basename $daemon_bin)
pid_file="/var/run/$daemon_name.pid"

data_dir=/var/lib/$daemon_name
conf_dir=/etc/$daemon_name

case "$1" in
    start)
        stat_busy "Starting $daemon_name daemon"
        if [ -z "$PID" ]; then
            [ -f $pid_file ] && rm -f $pid_file
            $daemon_bin "$conf_dir" "$data_dir/state" --fork $pid_file --syslog
            if [ $? -gt 0 ]; then
                stat_fail
                exit 1
            else
                add_daemon $daemon_name
                stat_done
            fi
        else
            stat_fail
            exit 1
        fi
        ;;

    stop)
        stat_busy "Stopping $daemon_name daemon"
        [ ! -z "$PID" ] && kill $PID &> /dev/null
        if [ $? -gt 0 ]; then
            stat_fail
            exit 1
        else
            rm -f $pid_file &> /dev/null
            rm_daemon $daemon_name
            stat_done
        fi
        ;;

    restart)
        $0 stop
        sleep 1
        $0 start
        ;;

    *)
        echo "usage: $0 {start|stop|restart}"
esac