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 | |
20040ab1 | 8 | # config: /etc/bpdyndnsd/bpdyndnsd.conf |
758bc3ab | 9 | # pidfile: /var/run/bpdyndnsd.pid |
dc50e618 BS |
10 | |
11 | # Source function library. | |
12 | . /etc/rc.d/init.d/functions | |
13 | ||
20040ab1 BS |
14 | # Configuration |
15 | . /etc/sysconfig/bpdyndnsd | |
dc50e618 | 16 | |
20040ab1 BS |
17 | # Prog name |
18 | progname="bpdyndnsd (dynamic DNS update daemon)" | |
19 | # User and group | |
20 | user=bpdyndnsd | |
21 | group=bpdyndnsd | |
22 | # Binary file | |
23 | prog=/usr/bin/bpdyndnsd | |
24 | # PID file | |
25 | pidfile=/var/run/bpdyndnsd.pid | |
dc50e618 | 26 | |
20040ab1 BS |
27 | test -x ${prog} || exit 0 |
28 | test -e /etc/bpdyndnsd/bpdyndnsd.conf || exit 0 | |
dc50e618 BS |
29 | |
30 | ## | |
31 | ## tool functions: | |
32 | ## | |
33 | ||
34 | is_running() { | |
35 | [ -f ${path_pidfile} ] || return 1 | |
36 | pid_from_file=`head -n1 ${path_pidfile}` | |
37 | [ -L /proc/${pid_from_file}/exe ] || return 1 | |
38 | [ "`readlink /proc/${pid_from_file}/exe`" = "${path_prg}" ] | |
39 | } | |
40 | # eo is_running | |
41 | ||
42 | ||
43 | ## | |
44 | ## the functions: | |
45 | ## | |
46 | ||
47 | start() { | |
20040ab1 BS |
48 | [ -f /var/lock/subsys/bpdyndnsd ] && stop |
49 | ||
50 | if [ $START_BPDYNDNSD -eq 1 ]; then | |
51 | # Check if this is really bpdyndnsd's pid file | |
52 | if [ -f $pidfile ]; then | |
53 | if ! grep -s -q "bpdyndnsd" /proc/`cat $pidfile`/cmdline; then | |
54 | echo "Unlinking non-bpdyndnsd pid file" | |
55 | rm -f $pidfile | |
56 | fi | |
57 | fi | |
dc50e618 | 58 | |
20040ab1 BS |
59 | echo -n "Starting $progname: " |
60 | $prog --daemon_mode 1 --syslog 1; | |
61 | RETVAL=$? | |
62 | [ $RETVAL -eq 0 ] && success || failure | |
63 | echo | |
64 | [ $RETVAL -eq 0 ] && touch /var/lock/subsys/bpdyndnsd | |
65 | fi | |
dc50e618 BS |
66 | } |
67 | ||
68 | stop() { | |
20040ab1 BS |
69 | if [ ! -f /var/lock/subsys/bpdyndnsd ]; then |
70 | return 0 | |
71 | fi | |
dc50e618 | 72 | |
20040ab1 | 73 | echo -n "Stopping $progname: " |
dc50e618 BS |
74 | killproc bpdyndnsd |
75 | RETVAL=$? | |
20040ab1 | 76 | [ $RETVAL -eq 0 ] && success || failure |
dc50e618 | 77 | echo |
20040ab1 | 78 | [ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/bpdyndnsd |
dc50e618 BS |
79 | } |
80 | ||
81 | reload() { | |
20040ab1 | 82 | echo -n "Reloading $progname: " |
dc50e618 BS |
83 | killproc bpdyndnsd -HUP |
84 | RETVAL=$? | |
20040ab1 | 85 | [ $RETVAL -eq 0 ] && success || failure |
dc50e618 | 86 | echo |
20040ab1 | 87 | } |
dc50e618 | 88 | |
20040ab1 BS |
89 | restart() { |
90 | stop | |
91 | start | |
dc50e618 BS |
92 | } |
93 | ||
20040ab1 | 94 | |
dc50e618 BS |
95 | ## |
96 | ## determine what we should do: | |
97 | ## | |
98 | case "$1" in | |
99 | start) | |
100 | start | |
101 | ;; | |
102 | stop) | |
103 | stop | |
104 | ;; | |
105 | status) | |
20040ab1 BS |
106 | status $prog |
107 | RETVAL=$? | |
dc50e618 BS |
108 | ;; |
109 | restart) | |
20040ab1 | 110 | restart |
dc50e618 BS |
111 | ;; |
112 | reload) | |
113 | reload | |
114 | ;; | |
115 | condrestart) | |
20040ab1 | 116 | [ -f /var/lock/subsys/bpdyndnsd ] && restart || : |
dc50e618 BS |
117 | ;; |
118 | *) | |
119 | echo "Usage: bpdyndnsd {start|stop|status|restart|reload|condrestart}" | |
20040ab1 | 120 | RETVAL=1 |
dc50e618 BS |
121 | esac |
122 | ||
123 | exit $RETVAL |