No Description

fwknopd.init 1.8KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  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. UCI_ENABLED=0
  9. START=60
  10. FWKNOPD_BIN=/usr/sbin/fwknopd
  11. start()
  12. {
  13. gen_confs
  14. $FWKNOPD_BIN
  15. }
  16. stop()
  17. {
  18. $FWKNOPD_BIN -K
  19. }
  20. restart()
  21. {
  22. stop;
  23. sleep 1;
  24. start;
  25. }
  26. reload()
  27. {
  28. gen_confs
  29. $FWKNOPD_BIN -R
  30. }
  31. gen_confs()
  32. {
  33. [ -f /tmp/access.conf.tmp ] && rm /tmp/access.conf.tmp
  34. config_cb() {
  35. local type="$1"
  36. local name="$2"
  37. if [ "$type" = "global" ]; then
  38. option_cb() {
  39. local option="$1"
  40. local value="$2"
  41. if [ "$option" = "uci_enabled" ] && [ "$value" -eq 1 ] ; then
  42. > /etc/fwknop/fwknopd.conf
  43. > /etc/fwknop/access.conf
  44. UCI_ENABLED=1
  45. fi
  46. }
  47. elif [ "$type" = "config" ]; then
  48. option_cb() {
  49. local option="$1"
  50. local value="$2"
  51. if [ $UCI_ENABLED ]; then
  52. echo "$option $value" >> /etc/fwknop/fwknopd.conf #writing each option to fwknopd.conf
  53. fi
  54. }
  55. elif [ "$type" = "access" ]
  56. then
  57. if [ -f /tmp/access.conf.tmp ] ; then
  58. cat /tmp/access.conf.tmp >> /etc/fwknop/access.conf
  59. rm /tmp/access.conf.tmp
  60. fi
  61. option_cb() {
  62. local option="$1"
  63. local value="$2"
  64. if [ $UCI_ENABLED ] && [ $option = "SOURCE" ]; then
  65. echo "$option $value" >> /etc/fwknop/access.conf #writing each option to access.conf
  66. fi
  67. if [ $UCI_ENABLED ] && [ $option != "SOURCE" ]; then
  68. echo "$option $value" >> /tmp/access.conf.tmp #writing each option to access.conf
  69. fi
  70. }
  71. fi
  72. }
  73. if [ -f /etc/config/fwknopd ]; then
  74. config_load fwknopd
  75. if [ -f /tmp/access.conf.tmp ] ; then
  76. cat /tmp/access.conf.tmp >> /etc/fwknop/access.conf
  77. rm /tmp/access.conf.tmp
  78. fi
  79. fi
  80. }