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