procd: Add wrapper for uci_validate_section()
[openwrt/openwrt.git] / package / base-files / files / etc / init.d / system
index 6388d62..a98a972 100755 (executable)
@@ -6,7 +6,7 @@ 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' \
@@ -15,11 +15,7 @@ validate_system_section()
 }
 
 system_config() {
-       local cfg="$1"
-
-       local hostname conloglevel buffersize timezone zonename
-
-       validate_system_section "${1}" || {
+       [ "$2" = 0 ] || {
                echo "validation failed"
                return 1
        }
@@ -27,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
@@ -35,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()