system 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  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:OpenWrt' \
  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" ] && ln -s "/usr/share/zoneinfo/$zonename" /tmp/localtime
  25. # apply timezone to kernel
  26. date -k
  27. }
  28. reload_service() {
  29. config_load system
  30. config_foreach system_config system
  31. }
  32. service_triggers()
  33. {
  34. procd_add_reload_trigger "system"
  35. procd_add_validation validate_system_section
  36. }
  37. start_service() {
  38. reload_service
  39. }