rc: $verbose conversion for OpenVPN

This commit is contained in:
Franco Fichtner 2016-12-09 10:55:49 +01:00
parent c1bd019603
commit 4346d549ca
2 changed files with 24 additions and 13 deletions

View File

@ -1026,7 +1026,7 @@ function openvpn_resync_csc()
}
}
function openvpn_prepare_all()
function openvpn_prepare_all($verbose = false)
{
global $config;
@ -1034,7 +1034,10 @@ function openvpn_prepare_all()
return;
}
log_error('Creating OpenVPN instances.');
if ($verbose) {
echo 'Creating OpenVPN instances...';
flush();
}
foreach (array('server', 'client') as $mode) {
if (isset($config['openvpn']["openvpn-{$mode}"])) {
@ -1043,6 +1046,10 @@ function openvpn_prepare_all()
}
}
}
if ($verbose) {
echo "done.\n";
}
}
function openvpn_resync($mode, $settings)
@ -1051,7 +1058,7 @@ function openvpn_resync($mode, $settings)
openvpn_restart($mode, $settings);
}
function openvpn_resync_all($interface = null)
function openvpn_resync_all($interface = null, $verbose = false)
{
global $config;
@ -1061,6 +1068,11 @@ function openvpn_resync_all($interface = null)
return;
}
if ($verbose) {
echo 'Syncing OpenVPN settings...';
flush();
}
if (!empty($interface)) {
log_error(sprintf(
'Resyncing OpenVPN instances for interface %s.',
@ -1081,6 +1093,10 @@ function openvpn_resync_all($interface = null)
}
openvpn_resync_csc();
if ($verbose) {
echo "done.\n";
}
}
function openvpn_get_active_servers($type = 'multipoint')

View File

@ -104,16 +104,11 @@ system_hosts_generate(true);
interfaces_loopback_configure(true);
system_syslogd_start(true);
/* set up interfaces */
system_console_mute();
openvpn_prepare_all();
interfaces_configure();
system_console_unmute();
/* start OpenVPN server & clients */
echo "Syncing OpenVPN settings...";
openvpn_resync_all();
echo "done.\n";
system_console_mute(); /* XXX move this further up */
openvpn_prepare_all(true);
interfaces_configure(); /* XXX needs $verbose conversion */
openvpn_resync_all(null, true);
system_console_unmute(); /* XXX move this further down */
system_resolvconf_generate(true);
filter_configure_sync(true);