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.

87 lines
1.8 KiB

  1. #!/bin/sh /etc/rc.common
  2. #
  3. # Fwknop is developed primarily by the people listed in the file 'AUTHORS'.
  4. # Copyright (C) 2009-2014 fwknop developers and contributors. For a full
  5. # list of contributors, see the file 'CREDITS'.
  6. #
  7. . /lib/functions.sh
  8. START=60
  9. FWKNOPD_BIN=/usr/sbin/fwknopd
  10. start()
  11. {
  12. gen_confs
  13. $FWKNOPD_BIN
  14. }
  15. stop()
  16. {
  17. $FWKNOPD_BIN -K
  18. }
  19. restart()
  20. {
  21. stop;
  22. sleep 1;
  23. start;
  24. }
  25. reload()
  26. {
  27. gen_confs
  28. $FWKNOPD_BIN -R
  29. }
  30. gen_confs()
  31. {
  32. [ -f /tmp/access.conf.tmp ] && rm /tmp/access.conf.tmp
  33. config_cb() {
  34. local type="$1"
  35. local name="$2"
  36. if [ "$type" = "global" ]; then
  37. option_cb() {
  38. local option="$1"
  39. local value="$2"
  40. if [ "$option" = "uci_enabled" ] && [ "$value" -eq 1 ] ; then
  41. > /etc/fwknop/fwknopd.conf
  42. > /etc/fwknop/access.conf
  43. UCI_ENABLED=1
  44. fi
  45. }
  46. elif [ "$type" = "config" ]; then
  47. option_cb() {
  48. local option="$1"
  49. local value="$2"
  50. if [ $UCI_ENABLED ]; then
  51. echo "$option $value" >> /etc/fwknop/fwknopd.conf #writing each option to fwknopd.conf
  52. fi
  53. }
  54. elif [ "$type" = "access" ]
  55. then
  56. if [ -f /tmp/access.conf.tmp ] ; then
  57. cat /tmp/access.conf.tmp >> /etc/fwknop/access.conf
  58. rm /tmp/access.conf.tmp
  59. fi
  60. option_cb() {
  61. local option="$1"
  62. local value="$2"
  63. if [ $UCI_ENABLED ] && [ $option = "SOURCE" ]; then
  64. echo "$option $value" >> /etc/fwknop/access.conf #writing each option to access.conf
  65. fi
  66. if [ $UCI_ENABLED ] && [ $option != "SOURCE" ]; then
  67. echo "$option $value" >> /tmp/access.conf.tmp #writing each option to access.conf
  68. fi
  69. }
  70. fi
  71. }
  72. if [ -f /etc/config/fwknopd ]; then
  73. config_load fwknopd
  74. if [ -f /tmp/access.conf.tmp ] ; then
  75. cat /tmp/access.conf.tmp >> /etc/fwknop/access.conf
  76. rm /tmp/access.conf.tmp
  77. fi
  78. fi
  79. }