packages/net/ez-ipupdate/files/ez-ipupdate.hotplug
jow 5a8c83cf92 [packages] ez-ipupdate: use network.sh to find device names
git-svn-id: svn://svn.openwrt.org/openwrt/packages@31944 3c298f89-4303-0410-b956-a3cf2f4a3e73
2012-05-28 15:08:19 +00:00

82 lines
1.6 KiB
Plaintext

NAME=ez-ipupdate
COMMAND=/usr/sbin/$NAME
case "$ACTION" in
ifup|ifdown)
cleanup() {
[ -e $1 ] && {
kill -9 $(cat $1)
rm $1
}
}
ddns() {
local cfg="$1"
config_get program $cfg program
[ "$program" = "$NAME" ] && {
config_get interface $cfg interface
[ "$interface" = "$INTERFACE" ] && {
network_get_device dev "$INTERFACE" || return
config_get enabled $cfg enabled
enabled=${enabled:-1}
config_get service $cfg service
config_get pidfile $cfg pidfile
pidfile=${pidfile:-/var/run/$NAME-$service-$dev.pid}
case "$ACTION" in
ifdown)
cleanup $pidfile
;;
*)
case "$enabled" in
1|yes|true)
[ ! -e $pidfile ] && {
config_get cache $cfg cache
[ -z "$cache" ] && cache=/tmp/$NAME-$service-$dev.cache
config_get config $cfg config
[ -z "$config" ] && {
config=/var/run/$NAME-$service-$dev.conf
config_get username $cfg username
config_get password $cfg password
config_get hostname $cfg hostname
service=${service:-"dyndns"}
config_get server $cfg server
server_line=""
[ -n "$server" ] && {
server_line="server=$server"
}
cat > $config <<EOF
service-type=$service
$server_line
user=$username:$password
host=$hostname
cache-file=$cache
pid-file=$pidfile
interface=$dev
quiet
EOF
}
$COMMAND -c $config 2>&1 | logger -t $NAME &
}
;;
*)
cleanup $pidfile
;;
esac
esac
}
}
}
. /lib/functions/network.sh
config_load ddns
config_foreach ddns ddns
;;
esac