Advertisement
Guest User

Untitled

a guest
Dec 11th, 2014
317
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.02 KB | None | 0 0
  1. [root@old_srv ~]# cat /etc/rc.d/openvpn
  2. #!/bin/bash
  3.  
  4. . /etc/rc.conf
  5. . /etc/rc.d/functions
  6.  
  7. CFGDIR="/etc/openvpn"
  8. STATEDIR="/var/run/openvpn"
  9.  
  10. case "$1" in
  11. start)
  12. stat_busy "Starting OpenVPN ... "
  13. success=0
  14. mkdir -p "${STATEDIR}"
  15. for cfg in "${CFGDIR}"/*.conf; do
  16. stat_append "$(basename "${cfg}" .conf) "
  17. /usr/sbin/openvpn --daemon --writepid "${STATEDIR}"/"$(basename "${cfg}" .conf)".pid --cd "${CFGDIR}" --config "${cfg}" || success=$?
  18. done
  19. if [ $success -eq 0 ]; then
  20. add_daemon openvpn
  21. stat_done
  22. else
  23. stat_fail
  24. fi
  25. ;;
  26. stop)
  27. stat_busy "Stopping OpenVPN ..."
  28. for pidfile in "${STATEDIR}"/*.pid; do
  29. stat_append "$(basename "${pidfile}" .pid) "
  30. kill $(cat "${pidfile}" 2>/dev/null) 2>/dev/null
  31. rm -f "${pidfile}"
  32. done
  33. rm_daemon openvpn
  34. stat_done
  35. ;;
  36. restart)
  37. $0 stop
  38. sleep 1
  39. $0 start
  40. ;;
  41. *)
  42. echo "usage: $0 {start|stop|restart}"
  43. esac
  44. exit 0
  45. [root@old_srv ~]#
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement