1 #!/bin/sh /etc/rc.common
2 # Copyright (C) 2008 OpenWrt.org
11 config_get hostname
"$cfg" hostname
12 hostname
="${hostname:-OpenWrt}"
21 config_get ifname
"$cfg" "ifname"
22 [ -n "$ifname" ] ||
return 0
23 [ -e $LIB_D/$ifname ] && return 0
25 config_get_bool enabled
"$cfg" "enabled" "1"
26 if [ "$enabled" -gt 0 ]; then
27 config_get remote_path
"$cfg" "remote_path"
28 [ -n "$remote_path" ] ||
return 0
29 config_get remote_host
"$cfg" "remote_host"
30 [ -n "$remote_host" ] ||
return 0
32 [ -x /usr
/bin
/wget
] && download_command
="wget http://$remote_host/$remote_path/${hostname}_$ifname -O $LIB_D/$ifname"
33 [ -n "$download_command" ] ||
return 0
35 while [ ! -e $LIB_D/$ifname ]; do
36 $download_command 2>/dev
/null
37 [ -e $LIB_D/$ifname ] && {
38 logger
-s -t "vnstat" "Successfully downloaded ${ifname}'s vnStat database backup"
39 [ -x /bin
/ln ] && ln -sf $LIB_D/$ifname $WWW_D/$ifname
48 [ -d $LIB_D ] || mkdir
-p $LIB_D
49 [ -d $WWW_D ] || mkdir
-p $WWW_D
52 config_foreach system_config system
55 config_foreach do_download interface