system 1008 B

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