tincd 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  1. #!/bin/sh
  2. # $FreeBSD: head/security/tinc/files/tincd.in 406095 2016-01-14 06:02:05Z dinoex $
  3. #
  4. # PROVIDE: tincd
  5. # REQUIRE: ipfilter FILESYSTEMS sysctl netif
  6. # BEFORE: SERVERS routing
  7. # KEYWORD: nojail
  8. #
  9. # Define these tincd_* variables in one of these files:
  10. # /etc/rc.conf
  11. # /etc/rc.conf.local
  12. # /etc/rc.conf.d/tincd
  13. #
  14. # tincd_enable (bool): Set to "NO" by default.
  15. # Set it to "YES" to enable tincd.
  16. # tincd_cfg (str): Set to "" by default.
  17. # Set it to NETNAMEs to use (ex.: "vpn1 vpn2").
  18. # tincd_flags (str): Set to "" by default.
  19. # Set it to flags to use (ex.: "-d 1 --logfile").
  20. #
  21. # DO NOT CHANGE THESE DEFAULT VALUES HERE
  22. tincd_enable=${tincd_enable:-"NO"}
  23. . /etc/rc.subr
  24. name="tincd"
  25. rcvar="tincd_enable"
  26. command="/usr/local/sbin/tincd"
  27. start_cmd="tincd_start"
  28. stop_cmd="tincd_stop"
  29. reload_cmd="tincd_reload"
  30. extra_commands="reload"
  31. procname=${command:-tincd}
  32. ldconfig_command="/sbin/ldconfig"
  33. load_rc_config $name
  34. tincd_start()
  35. {
  36. local setfib
  37. setfib=/usr/sbin/setfib
  38. ${ldconfig_command} -elf -m /usr/local/lib
  39. if test -z "${tincd_cfg}"
  40. then
  41. eval tincd_fib=\$${name}_fib
  42. if [ -n "${tincd_fib}" ]
  43. then
  44. procname="${command}"
  45. echo "Starting tincd"
  46. $setfib -F ${tincd_fib} $command ${command_args}
  47. else
  48. echo "Starting tincd"
  49. $command ${command_args}
  50. fi
  51. else
  52. for cfg in ${tincd_cfg}
  53. do
  54. eval tincd_fib=\$${name}_${cfg}_fib
  55. command_args="-n $cfg"
  56. if [ -n "${tincd_fib}" ]
  57. then
  58. procname="${command}"
  59. echo "Starting tincd"
  60. $setfib -F ${tincd_fib} $command ${command_args}
  61. else
  62. echo "Starting tincd for: ${cfg}"
  63. $command ${command_args}
  64. fi
  65. done
  66. fi
  67. # code deliberately borrowed from /etc/rc.d/netif
  68. if [ -f /etc/rc.d/ipfilter ] ; then
  69. # Resync ipfilter
  70. /etc/rc.d/ipfilter quietresync
  71. fi
  72. }
  73. tincd_stop()
  74. {
  75. if test -z "${tincd_cfg}"
  76. then
  77. echo "Stopping tincd"
  78. $command -k
  79. else
  80. for cfg in $tincd_cfg
  81. do
  82. echo "Stopping tincd for: ${cfg}"
  83. $command -n $cfg -k
  84. done
  85. fi
  86. }
  87. tincd_reload()
  88. {
  89. if test -z "${tincd_cfg}"
  90. then
  91. echo "Sending HUP to tincd"
  92. $command --kill=HUP
  93. else
  94. for cfg in $tincd_cfg
  95. do
  96. echo "Sending HUP to tincd for: ${cfg}"
  97. $command -n $cfg --kill=HUP
  98. done
  99. fi
  100. }
  101. run_rc_command "$1"
  102. # eof