Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I've got two different OpenVPN servers running on a box and I want to restart one of them (and leave the other untouched). I know I can restart all OpenVPN service using service openvpn restart, but then that restarts all OpenVPN services.

Is there a way to restart a specific OpenVPN server using the service command?

share|improve this question
add comment

2 Answers 2

up vote 3 down vote accepted

As the /etc/init.d/openvpn script (which is what gets executed by /usr/sbin/service) does not offer any options to do it (at least with ubuntu-10.04), the answer is no.

But since it is all scripts, you can just edit /etc/init.d/openvpn and add something like

named-restart)
  log_action_begin_msg "Restarting $DESC $2"
  PIDFILE="/var/run/openvpn.${2}.pid"
  NAME=$2
  log_daemon_msg "  Stopping VPN '$NAME'"
  stop_vpn
  sleep 1
  log_daemon_msg "  Restarting VPN '$NAME'"
  start_vpn
  if test -z "$PIDFILE" ; then
    log_warning_msg "  VPN $2 is not running."
  fi
  ;;

after the

case "$1" in

dirctive. Later, you can simply call service openvpn named-restart <vpn-name>.

share|improve this answer
add comment

the cmd "service openvpn restart" don't do distinction, it restart the services. I think an solution might be to reload the service. It will not cut the service doing, but reload the configuration file. So It might do the trick.

Else I don't think you can restart one of you vpn without restart the other with the service cmd.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.