531aa8cbc548743371eba0232d6cee5d67c4e20e
[openwrt/staging/yousong.git] / package / base-files / files / etc / init.d / system
1 #!/bin/sh /etc/rc.common
2 # Copyright (C) 2014 OpenWrt.org
3
4 START=10
5 USE_PROCD=1
6
7 validate_system_section()
8 {
9 uci_validate_section system system "${1}" \
10 'hostname:string:OpenWrt' \
11 'conloglevel:uinteger' \
12 'buffersize:uinteger' \
13 'timezone:string:UTC' \
14 'zonename:string'
15 }
16
17 system_config() {
18 local cfg="$1"
19
20 local hostname conloglevel buffersize timezone zonename
21
22 validate_system_section "${1}" || {
23 echo "validation failed"
24 return 1
25 }
26
27 echo "$hostname" > /proc/sys/kernel/hostname
28 [ -z "$conloglevel" -a -z "$buffersize" ] || dmesg ${conloglevel:+-n $conloglevel} ${buffersize:+-s $buffersize}
29 echo "$timezone" > /tmp/TZ
30 [ -n "$zonename" ] && [ -f "/usr/share/zoneinfo/$zonename" ] && \
31 ln -sf "/usr/share/zoneinfo/$zonename" /tmp/localtime && rm -f /tmp/TZ
32
33 # apply timezone to kernel
34 date -k
35 }
36
37 reload_service() {
38 config_load system
39 config_foreach system_config system
40 }
41
42 service_triggers()
43 {
44 procd_add_reload_trigger "system"
45 procd_add_validation validate_system_section
46 }
47
48 start_service() {
49 reload_service
50 }