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
·91 lines (83 loc) · 1.81 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
#!/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/sbin:/usr/local/sbin:${PATH}
export PATH
# See how we were called.
case "$1" in
start)
# Start daemon.
DELAY=`grep -v '^\s*#' $CONF | grep -i -m 1 "daemon" | awk -F '=' '{print $2}'`
if [ -z "$DELAY" ] ; then
DELAY="-daemon 300"
else
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