Subversion Repositories configs

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
3 - 1
#!/bin/sh
2
#
3
# ez-ipupdate     Starts and stops the ez-ipupdate daemon
4
#
5
#
6
# chkconfig: - 55 45
7
# processname: ez-ipupdate
8
# description: Check and update your IP to dynamic DNS Server.
9
### BEGIN INIT INFO
10
# Short-Description: Check and update your IP to dynamic DNS Server
11
# Provides: ez-ipupdate
12
# Required-Start: $local_fs $network
13
# Required-Stop: $local_fs
14
# Should-Start: $time
15
### END INIT INFO
16
 
17
ez_configdir=/etc/ez-ipupdate
18
ez_piddir=/var/run/ez-ipupdate
19
ez_bin=/usr/sbin/ez-ipupdate
20
 
21
# Make sure relevant files exist
22
[ -x "$ez_bin" -a -d "$ez_configdir" ] || exit 0
23
 
24
# Source function library.
25
. /etc/rc.d/init.d/functions
26
 
27
# Source networking configuration.
28
. /etc/sysconfig/network
29
 
30
# Check that networking is up.
31
[ "$NETWORKING" = "no" ] && exit 0
32
 
33
RETVAL=0
34
prog=ez-ipupdate
35
 
36
start() {
37
    # Start daemons.
38
    for ez_configfile in ${ez_configdir}/*.conf; do
39
	if [ -r ${ez_configfile} ]; then
40
	    # Don't run configurations that are not daemons
41
	    if ! grep -q '^ *daemon' ${ez_configfile}; then continue; fi
42
	    # Don't run configurations that run in foreground
43
	    if grep -q '^ *foreground' ${ez_configfile}; then continue; fi
44
	    ez_name=`basename $ez_configfile .conf`
45
	    if [ -f $ez_piddir/$ez_name.pid ]; then
46
		if status -p $ez_piddir/$ez_name.pid; then
47
		    continue
48
		fi
49
	    fi
50
	    echo -n $"Starting $prog for $ez_name: "
51
	    daemon $ez_bin --daemon --config-file $ez_configfile --pid-file $ez_piddir/$ez_name.pid
52
	    [ $? -ne 0 ] && RETVAL=1
53
	    echo
54
	fi
55
    done
56
}
57
 
58
stop() {
59
    # Stop daemons.
60
    for pidfile in ${ez_piddir}/*.pid; do
61
	if [ -r ${pidfile} ]; then
62
	    ez_name=`basename $pidfile .pid`
63
	    echo -n $"Shutting down $prog for $ez_name: "
64
	    killproc -p $pidfile $prog -QUIT
65
    	    [ $? -ne 0 ] && RETVAL=1
66
	    echo
67
	fi
68
    done
69
}
70
 
71
reload() {
72
    # Reload config by sending a SIGHUP.
73
    for pidfile in ${ez_piddir}/*.pid; do
74
	if [ -r ${pidfile} ]; then
75
	    ez_name=`basename $pidfile .pid`
76
	    echo -n $"Reloading $prog for $ez_name: "
77
	    killproc -p $pidfile $prog -HUP
78
	    [ $? -ne 0 ] && RETVAL=1
79
	    echo
80
	fi
81
    done
82
}
83
 
84
restart() {
85
    stop && start
86
    RETVAL=$?
87
}
88
 
89
# See how we were called.
90
case "$1" in
91
  start)
92
    start
93
    ;;
94
  stop)
95
    stop
96
    ;;
97
  restart)
98
    restart
99
    ;;
100
  reload|force-reload)
101
    reload
102
    ;;
103
  condrestart|try-restart)
104
    ls ${ez_piddir}/*.pid >/dev/null && restart
105
    ;;
106
  status)
107
    status $prog
108
    RETVAL=$?
109
    for ez_config in $ez_configdir/*.conf; do
110
	if [ -r $ez_config ]; then
111
	    ez_cache=`grep -E '^[[:space:]]*cache-file' $ez_config | cut -d "=" -f2`
112
	    ez_host=`grep -E '^[[:space:]]*host' $ez_config | cut -d "=" -f2`
113
	    ez_iface=`grep -E '^[[:space:]]*interface' $ez_config | cut -d "=" -f2`
114
	    [ -n "$ez_cache" ] && \
115
	    echo "Last IP update of $ez_host on $ez_iface: "`cat $ez_cache | cut -d "," -f2`
116
	fi
117
    done
118
    ;;
119
  *)
120
    echo "Usage: $0 {start|stop|restart|condrestart|reload|status}"
121
    exit 1
122
esac
123
 
124
exit $RETVAL