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.

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