mirror of
https://github.com/lucaspalomodevelop/core.git
synced 2026-03-14 08:34:39 +00:00
rc: more $verbose conversion
This commit is contained in:
parent
f783f5c4e2
commit
afa861d0cd
@ -337,10 +337,15 @@ function userHasPrivilege($userent, $privid = false)
|
||||
return true;
|
||||
}
|
||||
|
||||
function local_sync_accounts()
|
||||
function local_sync_accounts($verbose = false)
|
||||
{
|
||||
global $config;
|
||||
|
||||
if ($verbose) {
|
||||
echo 'Synchronizing user settings...';
|
||||
flush();
|
||||
}
|
||||
|
||||
/* remove local users to avoid uid conflicts */
|
||||
$fd = popen('/usr/sbin/pw usershow -a', 'r');
|
||||
if ($fd) {
|
||||
@ -390,6 +395,10 @@ function local_sync_accounts()
|
||||
local_group_set($group);
|
||||
}
|
||||
}
|
||||
|
||||
if ($verbose) {
|
||||
echo "done.\n";
|
||||
}
|
||||
}
|
||||
|
||||
function local_user_set(&$user)
|
||||
|
||||
@ -311,13 +311,22 @@ function filter_rules_sort()
|
||||
}
|
||||
}
|
||||
|
||||
function filter_pflog_start()
|
||||
function filter_pflog_start($verbose = false)
|
||||
{
|
||||
if (isvalidpid('/var/run/filterlog.pid')) {
|
||||
return;
|
||||
}
|
||||
|
||||
if ($verbose) {
|
||||
echo 'Starting PFLOG...';
|
||||
flush();
|
||||
}
|
||||
|
||||
mwexec('/usr/local/sbin/filterlog -i pflog0 -p /var/run/filterlog.pid');
|
||||
|
||||
if ($verbose) {
|
||||
echo "done.\n";
|
||||
}
|
||||
}
|
||||
|
||||
function filter_configure()
|
||||
|
||||
@ -42,10 +42,15 @@ function return_apinger_defaults()
|
||||
);
|
||||
}
|
||||
|
||||
function setup_gateways_monitor()
|
||||
function setup_gateways_monitor($verbose = false)
|
||||
{
|
||||
global $config;
|
||||
|
||||
if ($verbose) {
|
||||
echo 'Setting up gateway monitors...';
|
||||
flush();
|
||||
}
|
||||
|
||||
killbypid('/var/run/apinger.pid', 'TERM', true);
|
||||
@unlink('/var/run/apinger.status');
|
||||
|
||||
@ -373,11 +378,14 @@ EOD;
|
||||
$gateways_arr = return_gateways_array();
|
||||
if (!is_array($gateways_arr)) {
|
||||
log_error("No gateways to monitor. Apinger will not be run.");
|
||||
return;
|
||||
} else {
|
||||
file_put_contents('/var/etc/apinger.conf', $apingerconfig);
|
||||
mwexec_bg('/usr/local/sbin/apinger -c /var/etc/apinger.conf');
|
||||
}
|
||||
|
||||
file_put_contents('/var/etc/apinger.conf', $apingerconfig);
|
||||
mwexec_bg('/usr/local/sbin/apinger -c /var/etc/apinger.conf');
|
||||
if ($verbose) {
|
||||
echo "done.\n";
|
||||
}
|
||||
}
|
||||
|
||||
/* return the status of the apinger targets as a array */
|
||||
|
||||
@ -990,7 +990,7 @@ function interface_gif_configure(&$gif, $gifkey = "")
|
||||
foreach ($iflist as $ifname) {
|
||||
if ($config['interfaces'][$ifname]['if'] == $gifif) {
|
||||
if (get_interface_gateway($ifname) || get_interface_gateway_v6($ifname)) {
|
||||
system_routing_configure(false, $ifname);
|
||||
system_routing_configure($ifname);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -2874,7 +2874,7 @@ function interface_configure($interface = 'wan', $reloadall = false, $linkupeven
|
||||
}
|
||||
|
||||
if ($reloadall == true) {
|
||||
system_routing_configure(false, $interface);
|
||||
system_routing_configure($interface);
|
||||
|
||||
/* reload ipsec tunnels */
|
||||
ipsec_configure();
|
||||
|
||||
@ -432,7 +432,7 @@ function ipsec_convert_to_modp($index)
|
||||
return $convertion;
|
||||
}
|
||||
|
||||
function ipsec_configure()
|
||||
function ipsec_configure($verbose = false)
|
||||
{
|
||||
global $config, $p2_ealgos, $ipsec_loglevels;
|
||||
|
||||
@ -487,8 +487,8 @@ function ipsec_configure()
|
||||
@mkdir('/usr/local/etc/ipsec.d/ocspcerts');
|
||||
@mkdir('/usr/local/etc/ipsec.d/reqs');
|
||||
|
||||
if (file_exists("/var/run/booting")) {
|
||||
echo gettext("Configuring IPsec VPN...");
|
||||
if ($verbose) {
|
||||
echo 'Configuring IPsec VPN...';
|
||||
}
|
||||
|
||||
/* fastforwarding is not compatible with ipsec tunnels */
|
||||
@ -520,7 +520,7 @@ function ipsec_configure()
|
||||
|
||||
if (!is_ipaddr($rg)) {
|
||||
$filterdns_list[] = "{$rg}";
|
||||
if(! file_exists("/var/run/booting")) {
|
||||
if (!file_exists('/var/run/booting')) {
|
||||
$rg = resolve_retry($rg);
|
||||
}
|
||||
if (!is_ipaddr($rg)) {
|
||||
@ -1281,7 +1281,7 @@ EOD;
|
||||
killbypid('/var/run/filterdns-ipsec.pid');
|
||||
}
|
||||
|
||||
if (file_exists("/var/run/booting")) {
|
||||
if ($verbose) {
|
||||
echo "done.\n";
|
||||
}
|
||||
|
||||
|
||||
@ -28,7 +28,7 @@
|
||||
POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
function activate_powerd()
|
||||
function system_powerd_configure($verbose = false)
|
||||
{
|
||||
global $config;
|
||||
|
||||
@ -36,22 +36,37 @@ function activate_powerd()
|
||||
exec('/usr/bin/killall powerd');
|
||||
}
|
||||
|
||||
if(isset($config['system']['powerd_enable'])) {
|
||||
$ac_mode = "hadp";
|
||||
if (!empty($config['system']['powerd_ac_mode'])) {
|
||||
$ac_mode = $config['system']['powerd_ac_mode'];
|
||||
}
|
||||
if (!isset($config['system']['powerd_enable'])) {
|
||||
return;
|
||||
}
|
||||
|
||||
$battery_mode = "hadp";
|
||||
if (!empty($config['system']['powerd_battery_mode'])) {
|
||||
$battery_mode = $config['system']['powerd_battery_mode'];
|
||||
}
|
||||
if ($verbose) {
|
||||
echo 'Starting power daemon...';
|
||||
flush();
|
||||
}
|
||||
|
||||
$normal_mode = "hadp";
|
||||
if (!empty($config['system']['powerd_normal_mode'])) {
|
||||
$normal_mode = $config['system']['powerd_normal_mode'];
|
||||
}
|
||||
mwexec("/usr/sbin/powerd -b $battery_mode -a $ac_mode -n $normal_mode");
|
||||
$ac_mode = 'hadp';
|
||||
if (!empty($config['system']['powerd_ac_mode'])) {
|
||||
$ac_mode = $config['system']['powerd_ac_mode'];
|
||||
}
|
||||
|
||||
$battery_mode = 'hadp';
|
||||
if (!empty($config['system']['powerd_battery_mode'])) {
|
||||
$battery_mode = $config['system']['powerd_battery_mode'];
|
||||
}
|
||||
|
||||
$normal_mode = 'hadp';
|
||||
if (!empty($config['system']['powerd_normal_mode'])) {
|
||||
$normal_mode = $config['system']['powerd_normal_mode'];
|
||||
}
|
||||
|
||||
mwexecf(
|
||||
'/usr/sbin/powerd -b %s -a %s -n %s',
|
||||
array($battery_mode, $ac_mode, $normal_mode)
|
||||
);
|
||||
|
||||
if ($verbose) {
|
||||
echo "done.\n";
|
||||
}
|
||||
}
|
||||
|
||||
@ -415,7 +430,7 @@ function system_hostname_configure($verbose = false)
|
||||
}
|
||||
}
|
||||
|
||||
function system_routing_configure($verbose = false, $interface = '')
|
||||
function system_routing_configure($interface = '', $verbose = false)
|
||||
{
|
||||
global $config;
|
||||
|
||||
|
||||
@ -118,58 +118,36 @@ echo "done.\n";
|
||||
/* generate resolv.conf */
|
||||
system_resolvconf_generate();
|
||||
|
||||
/* setup pf */
|
||||
filter_configure_sync(true);
|
||||
|
||||
/* start pflog */
|
||||
echo "Starting PFLOG...";
|
||||
filter_pflog_start();
|
||||
echo "done.\n";
|
||||
|
||||
/* reconfigure our gateway monitor */
|
||||
echo "Setting up gateway monitors...";
|
||||
setup_gateways_monitor();
|
||||
echo "done.\n";
|
||||
|
||||
echo "Synchronizing user settings...";
|
||||
local_sync_accounts();
|
||||
echo "done.\n";
|
||||
|
||||
/* start ssh daemon */
|
||||
mwexec("/usr/local/etc/rc.sshd");
|
||||
|
||||
filter_pflog_start(true);
|
||||
setup_gateways_monitor(true);
|
||||
local_sync_accounts(true);
|
||||
system_webgui_configure(true);
|
||||
system_cron_configure(true);
|
||||
system_routing_configure(true);
|
||||
system_routing_configure('', true);
|
||||
|
||||
dnsmasq_configure_do(true);
|
||||
unbound_configure_do(true);
|
||||
services_dhcpd_configure('all', array(), true);
|
||||
system_hosts_generate();
|
||||
system_hosts_generate(true);
|
||||
services_dhcrelay_configure(true);
|
||||
services_dhcrelay6_configure(true);
|
||||
|
||||
/* dyndns service updates */
|
||||
mwexec("/usr/local/etc/rc.dyndns.update");
|
||||
mwexec("/usr/local/etc/rc.sshd"); /* XXX convert to plugin */
|
||||
mwexec("/usr/local/etc/rc.dyndns.update"); /* XXX convert to plugin */
|
||||
|
||||
/* Run a filter configure now that most all services have started */
|
||||
prefer_ipv4_or_ipv6();
|
||||
filter_configure_sync(true);
|
||||
|
||||
/* start all registered plugins */
|
||||
if (function_exists('plugins_configure')) {
|
||||
plugins_configure('bootup', true);
|
||||
}
|
||||
|
||||
/* start IPsec tunnels */
|
||||
$ipsec_dynamic_hosts = ipsec_configure();
|
||||
$ipsec_dynamic_hosts = ipsec_configure(true);
|
||||
|
||||
/* load graphing functions */
|
||||
enable_rrd_graphing(true);
|
||||
|
||||
/* If powerd is enabled, lets launch it */
|
||||
activate_powerd();
|
||||
|
||||
/* Set preferred protocol */
|
||||
prefer_ipv4_or_ipv6();
|
||||
system_powerd_configure(true);
|
||||
|
||||
/*
|
||||
* Give syslogd a kick after everything else has been
|
||||
@ -180,8 +158,7 @@ system_syslogd_start(true);
|
||||
|
||||
/* If there are ipsec dynamic hosts try again to reload the tunnels as rc.newipsecdns does */
|
||||
if ($ipsec_dynamic_hosts) {
|
||||
ipsec_configure();
|
||||
filter_configure();
|
||||
ipsec_configure(true);
|
||||
}
|
||||
|
||||
// generate configuration data for all installed templates
|
||||
|
||||
@ -168,7 +168,7 @@ if(isset($config['gifs']['gif']) && is_array($config['gifs']['gif'])){
|
||||
if (!empty($confif)) {
|
||||
interface_configure($confif);
|
||||
}
|
||||
system_routing_configure(false, $ifname);
|
||||
system_routing_configure($ifname);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -181,9 +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'])) {
|
||||
system_routing_configure(false, $interface);
|
||||
|
||||
/* reconfigure our gateway monitor */
|
||||
system_routing_configure($interface);
|
||||
setup_gateways_monitor();
|
||||
|
||||
if (is_ipaddr($curwanip)) {
|
||||
|
||||
@ -111,9 +111,7 @@ link_interface_to_track6($interface, "update");
|
||||
/* regenerate resolv.conf if DNS overrides are allowed */
|
||||
system_resolvconf_generate(true);
|
||||
|
||||
system_routing_configure(false, $interface);
|
||||
|
||||
/* reconfigure our gateway monitor */
|
||||
system_routing_configure($interface);
|
||||
setup_gateways_monitor();
|
||||
|
||||
/* signal filter reload */
|
||||
|
||||
@ -179,7 +179,7 @@ if ($_SERVER['REQUEST_METHOD'] === 'GET') {
|
||||
|
||||
system_resolvconf_generate(true);
|
||||
system_cron_configure();
|
||||
activate_powerd();
|
||||
system_powerd_configure();
|
||||
system_kernel_configure();
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user