package/*: remove useless explicit set of function returncode
[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
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" ] && ln -s "/usr/share/zoneinfo/$zonename" /tmp/localtime
31
32 # apply timezone to kernel
33 date -k
34 }
35
36 reload_service() {
37 config_load system
38 config_foreach system_config system
39 }
40
41 service_triggers()
42 {
43 procd_add_reload_trigger "system"
44 procd_add_validation validate_system_section
45 }
46
47 start_service() {
48 reload_service
49 }