base-files: split /etc/init.d/boot into 2 files
[openwrt/openwrt.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 return $?
17 }
18
19 system_config() {
20 local cfg="$1"
21
22 local hostname conloglevel buffersize timezone zonename
23
24 validate_system_section "${1}" || {
25 echo "validation failed"
26 return 1
27 }
28
29 echo "$hostname" > /proc/sys/kernel/hostname
30 [ -z "$conloglevel" -a -z "$buffersize" ] || dmesg ${conloglevel:+-n $conloglevel} ${buffersize:+-s $buffersize}
31 echo "$timezone" > /tmp/TZ
32 [ -n "$zonename" ] && [ -f "/usr/share/zoneinfo/$zonename" ] && ln -s "/usr/share/zoneinfo/$zonename" /tmp/localtime
33
34 # apply timezone to kernel
35 date -k
36 }
37
38 reload_service() {
39 config_load system
40 config_foreach system_config system
41 }
42
43 service_triggers()
44 {
45 procd_add_reload_trigger "system"
46 procd_add_validation validate_system_section
47 }
48
49 start_service() {
50 reload_service
51 }