luci-reload 924 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. #!/bin/sh
  2. . /lib/functions.sh
  3. apply_config() {
  4. config_get init "$1" init
  5. config_get exec "$1" exec
  6. config_get test "$1" test
  7. echo "$2" > "/var/run/luci-reload-status"
  8. [ -n "$init" ] && reload_init "$2" "$init" "$test"
  9. [ -n "$exec" ] && reload_exec "$2" "$exec" "$test"
  10. }
  11. reload_exec() {
  12. local service="$1"
  13. local ok="$3"
  14. set -- $2
  15. local cmd="$1"; shift
  16. [ -x "$cmd" ] && {
  17. echo "Reloading $service... "
  18. ( $cmd "$@" ) 2>/dev/null 1>&2
  19. [ -n "$ok" -a "$?" != "$ok" ] && echo '!!! Failed to reload' $service '!!!'
  20. }
  21. }
  22. reload_init() {
  23. [ -x /etc/init.d/$2 ] && /etc/init.d/$2 enabled && {
  24. echo "Reloading $1... "
  25. /etc/init.d/$2 reload >/dev/null 2>&1
  26. [ -n "$3" -a "$?" != "$3" ] && echo '!!! Failed to reload' $1 '!!!'
  27. }
  28. }
  29. lock "/var/run/luci-reload"
  30. config_load ucitrack
  31. for i in $*; do
  32. config_foreach apply_config $i $i
  33. done
  34. rm -f "/var/run/luci-reload-status"
  35. lock -u "/var/run/luci-reload"