Commit 2a45301e authored by Franco Fichtner's avatar Franco Fichtner

rc: $verbose conversion, simplify services_routing_enable()

parent daaf3acd
...@@ -989,12 +989,8 @@ function interface_gif_configure(&$gif, $gifkey = "") ...@@ -989,12 +989,8 @@ function interface_gif_configure(&$gif, $gifkey = "")
$iflist = get_configured_interface_list(); $iflist = get_configured_interface_list();
foreach ($iflist as $ifname) { foreach ($iflist as $ifname) {
if ($config['interfaces'][$ifname]['if'] == $gifif) { if ($config['interfaces'][$ifname]['if'] == $gifif) {
if (get_interface_gateway($ifname)) { if (get_interface_gateway($ifname) || get_interface_gateway_v6($ifname)) {
system_routing_configure($ifname); system_routing_configure(false, $ifname);
break;
}
if (get_interface_gateway_v6($ifname)) {
system_routing_configure($ifname);
break; break;
} }
} }
...@@ -1134,7 +1130,6 @@ function interfaces_configure() ...@@ -1134,7 +1130,6 @@ function interfaces_configure()
interfaces_group_setup(); interfaces_group_setup();
if (!file_exists("/var/run/booting")) { if (!file_exists("/var/run/booting")) {
/* reconfigure static routes (kernel may have deleted them) */
system_routing_configure(); system_routing_configure();
/* reload IPsec tunnels */ /* reload IPsec tunnels */
...@@ -2879,8 +2874,7 @@ function interface_configure($interface = 'wan', $reloadall = false, $linkupeven ...@@ -2879,8 +2874,7 @@ function interface_configure($interface = 'wan', $reloadall = false, $linkupeven
} }
if ($reloadall == true) { if ($reloadall == true) {
/* reconfigure static routes (kernel may have deleted them) */ system_routing_configure(false, $interface);
system_routing_configure($interface);
/* reload ipsec tunnels */ /* reload ipsec tunnels */
ipsec_configure(); ipsec_configure();
......
...@@ -415,10 +415,15 @@ function system_hostname_configure($verbose = false) ...@@ -415,10 +415,15 @@ function system_hostname_configure($verbose = false)
} }
} }
function system_routing_configure($interface = '') function system_routing_configure($verbose = false, $interface = '')
{ {
global $config; global $config;
if ($verbose) {
echo 'Setting up routes...';
flush();
}
$gatewayip = ""; $gatewayip = "";
$interfacegw = ""; $interfacegw = "";
$foundgw = false; $foundgw = false;
...@@ -516,6 +521,15 @@ function system_routing_configure($interface = '') ...@@ -516,6 +521,15 @@ function system_routing_configure($interface = '')
system_staticroutes_configure($interface); system_staticroutes_configure($interface);
set_sysctl(array(
'net.inet.ip.forwarding' => '1',
'net.inet6.ip6.forwarding' => '1'
));
if ($verbose) {
echo "done.\n";
}
return 0; return 0;
} }
...@@ -662,17 +676,8 @@ function system_staticroutes_configure($interface = '') ...@@ -662,17 +676,8 @@ function system_staticroutes_configure($interface = '')
return 0; return 0;
} }
function system_routing_enable() function system_syslogd_fixup_server($server)
{ {
global $config;
set_sysctl(array(
"net.inet.ip.forwarding" => "1",
"net.inet6.ip6.forwarding" => "1"
));
}
function system_syslogd_fixup_server($server) {
/* If it's an IPv6 IP alone, encase it in brackets */ /* If it's an IPv6 IP alone, encase it in brackets */
if (is_ipaddrv6($server)) { if (is_ipaddrv6($server)) {
return "[$server]"; return "[$server]";
...@@ -897,10 +902,15 @@ function system_clear_clog($logfile, $restart_syslogd = true) ...@@ -897,10 +902,15 @@ function system_clear_clog($logfile, $restart_syslogd = true)
} }
function system_webgui_configure() function system_webgui_configure($verbose = false)
{ {
global $config; global $config;
if ($verbose) {
echo 'Starting GUI...';
flush();
}
chdir('/usr/local/www'); chdir('/usr/local/www');
@unlink('/usr/local/www/csrf/csrf-secret.php'); @unlink('/usr/local/www/csrf/csrf-secret.php');
...@@ -974,8 +984,12 @@ function system_webgui_configure() ...@@ -974,8 +984,12 @@ function system_webgui_configure()
/* regenerate the php.ini files in case the setup has changed */ /* regenerate the php.ini files in case the setup has changed */
mwexec('/usr/local/etc/rc.php_ini_setup'); mwexec('/usr/local/etc/rc.php_ini_setup');
/* attempt to start lighthttpd and return true if ok */ /* start lighthttpd */
return !mwexec("/usr/local/sbin/lighttpd -f /var/etc/lighty-webConfigurator.conf"); mwexec('/usr/local/sbin/lighttpd -f /var/etc/lighty-webConfigurator.conf');
if ($verbose) {
echo "done.\n";
}
} }
/* /*
......
...@@ -138,12 +138,9 @@ echo "done.\n"; ...@@ -138,12 +138,9 @@ echo "done.\n";
/* start ssh daemon */ /* start ssh daemon */
mwexec("/usr/local/etc/rc.sshd"); mwexec("/usr/local/etc/rc.sshd");
/* start web server */ system_webgui_configure(true);
echo 'Starting webConfigurator...'. (system_webgui_configure() ? "done.\n" : "failed.\n");
system_cron_configure(true); system_cron_configure(true);
system_routing_configure(); system_routing_configure(true);
system_routing_enable();
dnsmasq_configure_do(true); dnsmasq_configure_do(true);
unbound_configure_do(true); unbound_configure_do(true);
services_dhcpd_configure('all', array(), true); services_dhcpd_configure('all', array(), true);
......
...@@ -43,7 +43,6 @@ if (set_networking_interfaces_ports()) { ...@@ -43,7 +43,6 @@ if (set_networking_interfaces_ports()) {
echo "Reloading interfaces..."; echo "Reloading interfaces...";
global $config; global $config;
$config = parse_config(); $config = parse_config();
system_routing_enable();
interfaces_configure(); interfaces_configure();
echo "done.\n"; echo "done.\n";
enable_rrd_graphing(); enable_rrd_graphing();
......
...@@ -168,7 +168,7 @@ if(isset($config['gifs']['gif']) && is_array($config['gifs']['gif'])){ ...@@ -168,7 +168,7 @@ if(isset($config['gifs']['gif']) && is_array($config['gifs']['gif'])){
if (!empty($confif)) { if (!empty($confif)) {
interface_configure($confif); interface_configure($confif);
} }
system_routing_configure($ifname); system_routing_configure(false, $ifname);
} }
} }
} }
...@@ -181,8 +181,7 @@ if(isset($config['gifs']['gif']) && is_array($config['gifs']['gif'])){ ...@@ -181,8 +181,7 @@ if(isset($config['gifs']['gif']) && is_array($config['gifs']['gif'])){
* could be failing back in which case we need to switch IPs back anyhow. * could be failing back in which case we need to switch IPs back anyhow.
*/ */
if (!is_ipaddr($oldip) || $curwanip != $oldip || !is_ipaddrv4($config['interfaces'][$interface]['ipaddr'])) { if (!is_ipaddr($oldip) || $curwanip != $oldip || !is_ipaddrv4($config['interfaces'][$interface]['ipaddr'])) {
/* reconfigure static routes (kernel may have deleted them) */ system_routing_configure(false, $interface);
system_routing_configure($interface);
/* reconfigure our gateway monitor */ /* reconfigure our gateway monitor */
setup_gateways_monitor(); setup_gateways_monitor();
......
...@@ -111,8 +111,7 @@ link_interface_to_track6($interface, "update"); ...@@ -111,8 +111,7 @@ link_interface_to_track6($interface, "update");
/* regenerate resolv.conf if DNS overrides are allowed */ /* regenerate resolv.conf if DNS overrides are allowed */
system_resolvconf_generate(true); system_resolvconf_generate(true);
/* reconfigure static routes (kernel may have deleted them) */ system_routing_configure(false, $interface);
system_routing_configure($interface);
/* reconfigure our gateway monitor */ /* reconfigure our gateway monitor */
setup_gateways_monitor(); setup_gateways_monitor();
......
...@@ -49,7 +49,6 @@ system_timezone_configure(); ...@@ -49,7 +49,6 @@ system_timezone_configure();
system_hostname_configure(); system_hostname_configure();
system_hosts_generate(); system_hosts_generate();
system_resolvconf_generate(); system_resolvconf_generate();
system_routing_enable();
interfaces_configure(); interfaces_configure();
services_dyndns_configure(); services_dyndns_configure();
system_cron_configure(); system_cron_configure();
......
...@@ -36,6 +36,5 @@ require_once("system.inc"); ...@@ -36,6 +36,5 @@ require_once("system.inc");
require_once("interfaces.inc"); require_once("interfaces.inc");
require_once("services.inc"); require_once("services.inc");
system_routing_enable();
interfaces_configure(); interfaces_configure();
filter_configure_sync(); filter_configure_sync();
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment