forked from ddclient/ddclient
-
Notifications
You must be signed in to change notification settings - Fork 0
/
sample-etc_rc.d_init.d_ddclient
executable file
·100 lines (93 loc) · 2.54 KB
/
sample-etc_rc.d_init.d_ddclient
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
#!/bin/bash
#
# ddclient This shell script takes care of starting and stopping
# ddclient.
#
# chkconfig: 2345 65 35
# description: ddclient provides support for updating dynamic DNS services.
CONF=/etc/ddclient/ddclient.conf
program=ddclient
[ -f $CONF ] || exit 0
system=unknown
if [ -f /etc/fedora-release ]; then
system=fedora
elif [ -f /etc/redhat-release ]; then
system=redhat
elif [ -f /etc/debian_version ]; then
system=debian
fi
PID=''
if [ "$system" = "fedora" ] || [ "$system" = "redhat" ]; then
. /etc/init.d/functions
PID=`pidofproc $program`
else
PID=`ps -aef | grep "$program - sleep" | grep -v grep | awk '{print $2}'`
fi
PATH=/usr/bin:/usr/local/bin:${PATH}
export PATH
# See how we were called.
case "$1" in
start)
# See if daemon=value is specified in the config file.
# Assumptions:
# * there are no quoted "#" characters before "daemon="
# (if there is a "#" it starts a comment)
# * "daemon=" does not appear in a password or value
# * if the interval value is 0, it is not quoted
INTERVAL=$(sed -e '
s/^\([^#]*[,[:space:]]\)\{0,1\}daemon=\([^,[:space:]]*\).*$/\2/
t quit
d
:quit
q
' "$CONF")
if [ -z "$DELAY" ] || [ "$DELAY" = "0" ]; then
DELAY="-daemon 300"
else
# use the interval specified in the config file
DELAY=''
fi
echo -n "Starting ddclient: "
if [ "$system" = "fedora" ] || [ "$system" = "redhat" ]; then
daemon $program $DELAY
else
ddclient $DELAY
fi
echo
;;
stop)
# Stop daemon.
echo -n "Shutting down ddclient: "
if [ -n "$PID" ]; then
if [ "$system" = "fedora" ] || [ "$system" = "redhat" ]; then
killproc $program
else
kill $PID
fi
else
echo "ddclient is not running"
fi
echo
;;
restart)
$0 stop
$0 start
;;
status)
if [ "$system" = "fedora" ] || [ "$system" = "redhat" ]; then
status $program
else
if test "$PID"; then
for p in $PID; do
echo "$program (pid $p) is running"
done
else
echo "$program is stopped"
fi
fi
;;
*)
echo "Usage: ddclient {start|stop|restart|status}"
exit 1
esac
exit 0