17:39 - Friday, 18 April 2014

How To Restart Specific OpenVPN Services Using “service”

#Topics: restart openvpn service,cmd restart vpn,how to restart openvpnas,how to restart vpn service on linux,how to restart vpn service ubuntu

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?

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 .

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

Advertisement

Comment