Project

General

Profile

openvpn.inc.patch

Jason Crowley, 01/24/2014 08:07 AM

View differences:

openvpn.inc 2014-01-23 10:45:35.000000000 -0600
767 767
	$vpnid = $settings['vpnid'];
768 768
	$mode_id = $mode.$vpnid;
769 769

  
770
	if ($mode == "server")
771
		$devname = "ovpns{$vpnid}";
772
	else
773
		$devname = "ovpnc{$vpnid}";
774

  
770 775
	/* kill the process if running */
771 776
	$pfile = $g['varrun_path']."/openvpn_{$mode_id}.pid";
772 777
	if (file_exists($pfile)) {
......
803 808
	openvpn_clear_route($mode, $settings);
804 809
	mwexec_bg("/usr/local/sbin/openvpn --config {$fpath}");
805 810

  
811
	/* look for interface to come up before continuing */
812
	$i = 1;
813
	while(mwexec("/sbin/ifconfig $devname | grep '[<,]UP[,>]'", true)) {
814
		if($g['debug'])
815
			log_error("Sleeping 1 second waiting for openvpn interface to come up attempt: $i of 10.\n");
816
		sleep(1);
817
		$i++;
818
		if ($i > 10) {
819
			log_error("Timeout waiting for openvpn interface $devname to come up.\n");
820
			break;
821
		}
822
	}
823

  
806 824
	if (!$g['booting'])
807 825
		send_event("filter reload");
808 826
}