[package] ez-ipudate: fix config generator to permit default server
[openwrt/svn-archive/archive.git] / net / ez-ipupdate / files / ez-ipupdate.hotplug
1 NAME=ez-ipupdate
2 COMMAND=/usr/sbin/$NAME
3
4 case "$ACTION" in
5 ifup|ifdown)
6 cleanup() {
7 [ -e $1 ] && {
8 kill -9 $(cat $1)
9 rm $1
10 }
11 }
12
13 ddns() {
14 local cfg="$1"
15 config_get program $cfg program
16 [ "$program" = "$NAME" ] && {
17 config_get interface $cfg interface
18 [ "$interface" = "$INTERFACE" ] && {
19 config_get dev "$INTERFACE" ifname
20
21 config_get enabled $cfg enabled
22 enabled=${enabled:-1}
23
24 config_get service $cfg service
25
26 config_get pidfile $cfg pidfile
27 pidfile=${pidfile:-/var/run/$NAME-$service-$dev.pid}
28
29 case "$ACTION" in
30 ifdown)
31 cleanup $pidfile
32 ;;
33 *)
34 case "$enabled" in
35 1|yes|true)
36 [ ! -e $pidfile ] && {
37 config_get cache $cfg cache
38 [ -z "$cache" ] && cache=/tmp/$NAME-$service-$dev.cache
39
40 config_get config $cfg config
41 [ -z "$config" ] && {
42 config=/var/run/$NAME-$service-$dev.conf
43 config_get username $cfg username
44 config_get password $cfg password
45 config_get hostname $cfg hostname
46 service=${service:-"dyndns"}
47 config_get server $cfg server
48 server_line=""
49 [ -n "$server" ] && {
50 server_line="server=$server"
51 }
52 cat > $config <<EOF
53 service-type=$service
54 $server_line
55 user=$username:$password
56 host=$hostname
57 cache-file=$cache
58 pid-file=$pidfile
59 interface=$dev
60 quiet
61 EOF
62 }
63
64 $COMMAND -c $config 2>&1 | logger -t $NAME &
65 }
66 ;;
67 *)
68 cleanup $pidfile
69 ;;
70 esac
71 esac
72 }
73 }
74 }
75
76
77 include /lib/network
78 scan_interfaces
79 config_load ddns
80
81 config_foreach ddns ddns
82 ;;
83 esac