openvpn.init 511 B

12345678910111213141516171819202122232425262728293031
  1. #!/bin/sh
  2. #PKG openvpn
  3. #INIT 60
  4. . /etc/rc.conf
  5. case $1 in
  6. autostop) ;;
  7. autostart)
  8. test x"${openvpn:-NO}" = x"NO" && exit 0
  9. test x"$openvpn" = x"DAEMON" && test -x /bin/mksh && exec mksh -T- $0 start
  10. exec sh $0 start
  11. ;;
  12. start)
  13. for c in $(ls /etc/openvpn/*.conf 2>&-); do
  14. /usr/sbin/openvpn --cd /etc/openvpn --config "$c" --daemon
  15. done
  16. ;;
  17. stop)
  18. kill $(pgrep -f /usr/sbin/openvpn)
  19. ;;
  20. restart)
  21. sh $0 stop
  22. sleep 3
  23. sh $0 start
  24. ;;
  25. *)
  26. echo "Usage: $0 {start | stop | restart}"
  27. exit 1
  28. ;;
  29. esac
  30. exit $?