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 = "")
$iflist = get_configured_interface_list();
foreach ($iflist as $ifname) {
if ($config['interfaces'][$ifname]['if'] == $gifif) {
if (get_interface_gateway($ifname)) {
system_routing_configure($ifname);
break;
}
if (get_interface_gateway_v6($ifname)) {
system_routing_configure($ifname);
if (get_interface_gateway($ifname) || get_interface_gateway_v6($ifname)) {
system_routing_configure(false, $ifname);
break;
}
}
......@@ -1134,7 +1130,6 @@ function interfaces_configure()
interfaces_group_setup();
if (!file_exists("/var/run/booting")) {
/* reconfigure static routes (kernel may have deleted them) */
system_routing_configure();
/* reload IPsec tunnels */
......@@ -2879,8 +2874,7 @@ function interface_configure($interface = 'wan', $reloadall = false, $linkupeven
}
if ($reloadall == true) {
/* reconfigure static routes (kernel may have deleted them) */
system_routing_configure($interface);
system_routing_configure(false, $interface);
/* reload ipsec tunnels */
ipsec_configure();
......
......@@ -415,10 +415,15 @@ function system_hostname_configure($verbose = false)
}
}
function system_routing_configure($interface = '')
function system_routing_configure($verbose = false, $interface = '')
{
global $config;
if ($verbose) {
echo 'Setting up routes...';
flush();
}
$gatewayip = "";
$interfacegw = "";
$foundgw = false;
......@@ -516,6 +521,15 @@ function system_routing_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;
}
......@@ -662,17 +676,8 @@ function system_staticroutes_configure($interface = '')
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 (is_ipaddrv6($server)) {
return "[$server]";
......@@ -897,10 +902,15 @@ function system_clear_clog($logfile, $restart_syslogd = true)
}
function system_webgui_configure()
function system_webgui_configure($verbose = false)
{
global $config;
if ($verbose) {
echo 'Starting GUI...';
flush();
}
chdir('/usr/local/www');
@unlink('/usr/local/www/csrf/csrf-secret.php');
......@@ -974,8 +984,12 @@ function system_webgui_configure()
/* regenerate the php.ini files in case the setup has changed */
mwexec('/usr/local/etc/rc.php_ini_setup');
/* attempt to start lighthttpd and return true if ok */
return !mwexec("/usr/local/sbin/lighttpd -f /var/etc/lighty-webConfigurator.conf");
/* start lighthttpd */
mwexec('/usr/local/sbin/lighttpd -f /var/etc/lighty-webConfigurator.conf');
if ($verbose) {
echo "done.\n";
}
}
/*
......
......@@ -138,12 +138,9 @@ echo "done.\n";
/* start ssh daemon */
mwexec("/usr/local/etc/rc.sshd");
/* start web server */
echo 'Starting webConfigurator...'. (system_webgui_configure() ? "done.\n" : "failed.\n");
system_webgui_configure(true);
system_cron_configure(true);
system_routing_configure();
system_routing_enable();
system_routing_configure(true);
dnsmasq_configure_do(true);
unbound_configure_do(true);
services_dhcpd_configure('all', array(), true);
......
......@@ -43,7 +43,6 @@ if (set_networking_interfaces_ports()) {
echo "Reloading interfaces...";
global $config;
$config = parse_config();
system_routing_enable();
interfaces_configure();
echo "done.\n";
enable_rrd_graphing();
......
......@@ -168,7 +168,7 @@ if(isset($config['gifs']['gif']) && is_array($config['gifs']['gif'])){
if (!empty($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'])){
* 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'])) {
/* reconfigure static routes (kernel may have deleted them) */
system_routing_configure($interface);
system_routing_configure(false, $interface);
/* reconfigure our gateway monitor */
setup_gateways_monitor();
......
......@@ -111,8 +111,7 @@ link_interface_to_track6($interface, "update");
/* regenerate resolv.conf if DNS overrides are allowed */
system_resolvconf_generate(true);
/* reconfigure static routes (kernel may have deleted them) */
system_routing_configure($interface);
system_routing_configure(false, $interface);
/* reconfigure our gateway monitor */
setup_gateways_monitor();
......
......@@ -49,7 +49,6 @@ system_timezone_configure();
system_hostname_configure();
system_hosts_generate();
system_resolvconf_generate();
system_routing_enable();
interfaces_configure();
services_dyndns_configure();
system_cron_configure();
......
......@@ -36,6 +36,5 @@ require_once("system.inc");
require_once("interfaces.inc");
require_once("services.inc");
system_routing_enable();
interfaces_configure();
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