You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

69 lines
1.5 KiB

  1. #!/bin/sh /etc/rc.common
  2. #
  3. # Copyright (C) 2019 Mister Benjamin <144dbspl@gmail.com>
  4. NAME='etherwake-nfqueue'
  5. START=60
  6. USE_PROCD=1
  7. PROGRAM=${NAME}
  8. start_service()
  9. {
  10. local value
  11. config_load ${NAME}
  12. config_get_bool value setup sudo 0
  13. [ "${value}" -ne 0 ] && PROGRAM="sudo ${PROGRAM}"
  14. config_get_bool value setup debug 0
  15. if [ "${value}" -ne 0 ]; then
  16. PROCD_DEBUG=1
  17. append PROGRAM '-D'
  18. fi
  19. config_foreach start_instance target
  20. }
  21. start_instance()
  22. {
  23. local section="$1"
  24. local value name mac
  25. config_get_bool value "${section}" enabled 1
  26. [ "${value}" -ne 1 ] && return 0
  27. config_get value "${section}" name
  28. [ -z "${value}" ] && value="{section}"
  29. name=${value}
  30. config_get mac "${section}" mac
  31. [ -z "${mac}" ] && {
  32. echo "${initscript}: Target ${name} has no MAC address"
  33. return 1
  34. }
  35. procd_open_instance ${name}
  36. procd_set_param command ${PROGRAM}
  37. procd_set_param respawn
  38. procd_set_param stdout 1
  39. procd_set_param stderr 1
  40. config_get_bool value "${section}" broadcast 0
  41. [ "${value}" -ne 0 ] && procd_append_param command -b
  42. config_get value "${section}" interface
  43. [ -n "${value}" ] && procd_append_param command -i "${value}"
  44. config_get value "${section}" password
  45. [ -n "${value}" ] && procd_append_param command -p "${value}"
  46. config_get value "${section}" nfqueue_num 0
  47. procd_append_param command -q "${value}"
  48. procd_append_param command "${mac}"
  49. procd_close_instance
  50. }