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.

93 lines
2.4 KiB

  1. #!/bin/sh /etc/rc.common
  2. START=90
  3. STOP=89
  4. USE_PROCD=1
  5. service_triggers() {
  6. procd_add_reload_trigger "chilli"
  7. }
  8. config_cb() {
  9. chilli_conf="/var/run/chilli_${2}.conf"
  10. [ -e "$chilli_conf" ] && rm -f "$chilli_conf"
  11. }
  12. option_cb() {
  13. case "$1" in
  14. # ignored/internal settings
  15. disabled)
  16. ;;
  17. # UCI settings
  18. network)
  19. . /lib/functions/network.sh
  20. local ifname
  21. network_get_device ifname "$2"
  22. echo "dhcpif=\"$ifname\"" >> "$chilli_conf"
  23. ;;
  24. # boolean settings
  25. acctupdate|chillixml|coanoipcheck|debug|dhcpbroadcast|dhcpmacset|dhcpnotidle|\
  26. dhcpradius|dnsparanoia|domaindnslocal|eapolenable|fg|forgiving|framedservice|\
  27. ieee8021q|injectwispr|ipv6|ipv6only|layer3|locationcopycalled|\
  28. locationimmediateupdate|locationopt82|locationstopstart|macallowlocal|\
  29. macauth|macauthdeny|macreauth|mmapring|mschapv2|noarpentries|noc2c|nochallenge|\
  30. nodynip|noradallow|nosystemdns|nouamsuccess|nousergardendata|nowispr1|nowispr2|\
  31. only8021q|openidauth|papalwaysok|patricia|postauthproxyssl|proxymacaccept|\
  32. proxyonacct|radiusoriginalurl|radsec|redir|redirdnsreq|redirssl|redirurl|reload|\
  33. routeonetone|scalewin|seskeepalive|statusfilesave|strictdhcp|strictmacauth|\
  34. swapoctets|uamallowpost|uamanydns|uamanyip|uamauthedallowed|uamgardendata|\
  35. uamnatanyip|uamotherdata|uamuissl|usetap|vlanlocation|wpaguests)
  36. [ "$2" = "true" -o "$2" = "1" ] && echo "$1" >> "$chilli_conf"
  37. ;;
  38. *)
  39. echo "$1=\"$2\"" >> "$chilli_conf"
  40. ;;
  41. esac
  42. }
  43. start_chilli() {
  44. local cfg="$1"
  45. local base="/var/run/chilli_${cfg}"
  46. config_get_bool disabled "$1" 'disabled' 1
  47. [ $disabled = 1 ] && return
  48. procd_open_instance "$cfg"
  49. procd_set_param command /usr/sbin/chilli
  50. procd_set_param file "$chilli_conf"
  51. procd_append_param command \
  52. --fg \
  53. --conf "${base}.conf" \
  54. --pidfile "${base}.pid" \
  55. --cmdsocket "${base}.sock" \
  56. --unixipc "${base}.ipc"
  57. procd_set_param respawn
  58. procd_set_param stdout 1
  59. procd_set_param stderr 1
  60. procd_close_instance
  61. }
  62. start_service() {
  63. config_load chilli
  64. config_foreach start_chilli chilli
  65. }
  66. stop_service() {
  67. rm -f /var/run/chilli_*
  68. }
  69. reload_chilli() {
  70. local pid
  71. local cfg="$1"
  72. local base="/var/run/chilli_${cfg}"
  73. if [ -f "${base}.pid" ]; then
  74. pid="$(cat "${base}.pid")"
  75. [ -f "/var/run/chilli.${pid}.cfg.bin" ] && rm -f "/var/run/chilli.${pid}.cfg.bin"
  76. chilli_query -s "${base}.sock" reload
  77. fi
  78. }
  79. reload_service() {
  80. config_load chilli
  81. config_foreach reload_chilli chilli
  82. }