procd: Add wrapper for uci_validate_section()
[openwrt/openwrt.git] / package / base-files / files / etc / init.d / system
index 24a9fde..a98a972 100755 (executable)
@@ -6,22 +6,16 @@ USE_PROCD=1
 
 validate_system_section()
 {
-       uci_validate_section system system "${1}" \
+       uci_load_validate system system "$1" "$2" \
                'hostname:string:OpenWrt' \
                'conloglevel:uinteger' \
                'buffersize:uinteger' \
                'timezone:string:UTC' \
                'zonename:string'
-
-       return $?
 }
 
 system_config() {
-       local cfg="$1"
-
-       local hostname conloglevel buffersize timezone zonename
-
-       validate_system_section "${1}" || {
+       [ "$2" = 0 ] || {
                echo "validation failed"
                return 1
        }
@@ -29,7 +23,8 @@ system_config() {
        echo "$hostname" > /proc/sys/kernel/hostname
        [ -z "$conloglevel" -a -z "$buffersize" ] || dmesg ${conloglevel:+-n $conloglevel} ${buffersize:+-s $buffersize}
        echo "$timezone" > /tmp/TZ
-       [ -n "$zonename" ] && [ -f "/usr/share/zoneinfo/$zonename" ] && ln -s "/usr/share/zoneinfo/$zonename" /tmp/localtime
+       [ -n "$zonename" ] && [ -f "/usr/share/zoneinfo/$zonename" ] && \
+               ln -sf "/usr/share/zoneinfo/$zonename" /tmp/localtime && rm -f /tmp/TZ
 
        # apply timezone to kernel
        date -k
@@ -37,7 +32,7 @@ system_config() {
 
 reload_service() {
        config_load system
-       config_foreach system_config system
+       config_foreach validate_system_section system system_config
 }
 
 service_triggers()