Useing initlog to start process.
[bpdyndnsd] / scripts / bpdyndnsd
1 #! /bin/sh
2 #
3 # bpdyndnsd
4 #
5 # chkconfig: - 93 04
6 # description: Bullet proof dynamic DNS update daemon.
7 # processname: bpdyndnsd
8
9 # Source function library.
10 . /etc/rc.d/init.d/functions
11
12 # define the paths to the binaries:
13 path_prg=/usr/intranator/bin/bpdyndnsd
14
15 # other paths:
16 path_pidfile=/var/run/bpdyndnsd.pid
17
18
19 ##
20 ## tool functions:
21 ##
22
23 is_running() {
24     [ -f ${path_pidfile} ] || return 1
25     pid_from_file=`head -n1 ${path_pidfile}`
26     [ -L /proc/${pid_from_file}/exe ] || return 1
27     [ "`readlink /proc/${pid_from_file}/exe`" = "${path_prg}" ]
28 }
29 # eo is_running
30
31
32 ##
33 ## the functions:
34 ##
35
36 start() {
37    echo -n "Starting bpdyndnsd: "
38
39    initlog -c "${path_prg} --daemon_mode 1 --syslog 1" && success || failure
40    RETVAL=$?
41    echo
42
43    if [ $RETVAL -eq 0 ] ; then
44       touch /var/lock/subsys/bpdyndnsd
45    fi
46    return $RETVAL
47 }
48
49 stop() {
50     echo -n "Stopping bpdyndnsd: "
51
52     killproc bpdyndnsd
53     RETVAL=$?
54     echo
55
56     rm -f /var/lock/subsys/bpdyndnsd
57     return $RETVAL
58 }
59
60 reload() {
61     echo -n "Reloading bpdyndnsd: "
62
63     killproc bpdyndnsd -HUP
64     RETVAL=$?
65     echo
66
67     return $RETVAL
68 }
69
70 ##
71 ## determine what we should do:
72 ##
73 case "$1" in
74     start)
75         start
76         ;;
77     stop)
78         stop
79         ;;
80     status)
81         status bpdyndnsd
82         ;;
83     restart)
84         stop
85         start
86         ;;
87     reload)
88         reload
89         ;;
90     condrestart)
91         if [ -f /var/lock/subsys/bpdyndnsd ]; then
92             stop
93             start
94         fi
95         ;;
96     *)
97         echo "Usage: bpdyndnsd {start|stop|status|restart|reload|condrestart}"
98         exit 1
99 esac
100
101 exit $RETVAL