system 1.0 KB

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