#!/sbin/runscript # Copyright 1999-2004 Gentoo Foundation # Distributed under the terms of the GNU General Public License v2 # $Header: /var/cvsroot/gentoo-x86/net-dns/ez-ipupdate/files/ez-ipupdate.rc6,v 1.1 2004/08/15 11:06:00 aliz Exp $ opts="${opts} reload update" depend() { need net } checkconfig() { if [ ! -e /etc/ez-ipupdate.conf -a ! -d /etc/ez-ipupdate.d ]; then eerror "You need a /etc/ez-ipupdate.conf containing" eerror "your username and password or the service" eerror "you wish to utilize." eerror "Alternatively, you can place one file per" eerror "host in /etc/ez-ipupdate.d" return 1 fi return 0 } for_each_host() { if [ -f /etc/ez-ipupdate.conf ]; then local host=$( egrep "^host=" /etc/ez-ipupdate.conf | awk -F'=' '{print $2}' ) local interface=$( egrep "^interface=" /etc/ez-ipupdate.conf | awk -F'=' '{print $2}' ) $1 /etc/ez-ipupdate.conf $host $interface /var/run/ez-ipupdate.pid /var/cache/ez-ipupdate.cache || return 1 fi if [ -d /etc/ez-ipupdate.d ]; then [ -d /var/run/ez-ipupdate ] || mkdir /var/run/ez-ipupdate [ -d /var/cache/ez-ipupdate ] || mkdir /var/cache/ez-ipupdate for config in /etc/ez-ipupdate.d/*; do local host=$( egrep "^host=" $config | awk -F'=' '{print $2}' ) local interface=$( egrep "^interface=" $config | awk -F'=' '{print $2}' ) local pid_file=$( egrep "^pid-file=" $config | awk -F'=' '{print $2}' ) local cache_file=$( egrep "^cache-file=" $config | awk -F'=' '{print $2}' ) [ -n "$host" ] || host=$( basename $config ) [ -n "$pid_file" ] || pid_file="/var/run/ez-ipupdate/$( basename $config )" [ -n "$cache_file" ] || cache_file="/var/cache/ez-ipupdate/$( basename $config )" $1 $config $host $interface $pid_file $cache_file || return 1 done fi } start_host() { ebegin " for $2 on $3" start-stop-daemon -p $4 --start --quiet --exec /usr/bin/ez-ipupdate -- -c $1 -d -h $2 -F $4 -b $5 eend $? } stop_host() { ebegin " $2 on $3" kill -QUIT `cat $4` eend $? return 0 } reload_host() { ebegin " $2 on $3" kill -HUP `cat $4` eend $? return 0 } update_host() { ebegin " $2 on $3" kill -TERM `cat $4` eend $? return 0 } start() { checkconfig || return 1 ebegin "Starting ez-ipupdate" for_each_host start_host eend $? } stop() { ebegin "Stopping ez-ipupdate" for_each_host stop_host eend $? } reload() { ebegin "Reloading configfile(s)" for_each_host reload_host eend $? } update() { ebegin "Forcing update" for_each_host update_host eend $? }