Commit 3bec4f02 authored by Franco Fichtner's avatar Franco Fichtner

rc: merge rc.loader and assorted additions

parent 7876c837
...@@ -21,19 +21,6 @@ EOF ...@@ -21,19 +21,6 @@ EOF
cat /etc/rc.bak >> /etc/rc cat /etc/rc.bak >> /etc/rc
rm -f /etc/rc.bak rm -f /etc/rc.bak
echo "Updating /boot/loader.conf"
touch /boot/loader.conf
cp /boot/loader.conf /boot/loader.conf.bak
(grep -v loader_brand /boot/loader.conf.bak; \
echo 'loader_brand="opnsense"') > /boot/loader.conf
cp /boot/loader.conf /boot/loader.conf.bak
(grep -v loader_logo /boot/loader.conf.bak; \
echo 'loader_logo="hourglass"') > /boot/loader.conf
cp /boot/loader.conf /boot/loader.conf.bak
(grep -v loader_menu_title /boot/loader.conf.bak; \
echo 'loader_menu_title=""') > /boot/loader.conf
rm -f /boot/loader.conf.bak
echo "Writing package version" echo "Writing package version"
mkdir -p /usr/local/opnsense/version mkdir -p /usr/local/opnsense/version
if [ -f /usr/local/opnsense/version/opnsense ]; then if [ -f /usr/local/opnsense/version/opnsense ]; then
...@@ -56,3 +43,6 @@ echo "Reloading GUI configuration" ...@@ -56,3 +43,6 @@ echo "Reloading GUI configuration"
if pgrep -q php-cgi; then if pgrep -q php-cgi; then
pkill -HUP php-cgi pkill -HUP php-cgi
fi fi
echo "Reloading firmware configuration"
/usr/local/etc/rc.configure_firmware
...@@ -9,14 +9,6 @@ cp /etc/shells /etc/shells.bak ...@@ -9,14 +9,6 @@ cp /etc/shells /etc/shells.bak
(grep -v /usr/local/etc/rc.installer /etc/shells.bak) > /etc/shells (grep -v /usr/local/etc/rc.installer /etc/shells.bak) > /etc/shells
rm -f /etc/shells.bak rm -f /etc/shells.bak
echo "Updating /boot/loader.conf"
touch /boot/loader.conf
cp /boot/loader.conf /boot/loader.conf.bak
(grep -v loader_brand /boot/loader.conf.bak) > /boot/loader.conf
cp /boot/loader.conf /boot/loader.conf.bak
(grep -v loader_logo /boot/loader.conf.bak) > /boot/loader.conf
rm -f /boot/loader.conf.bak
echo "Unhooking from /etc/rc" echo "Unhooking from /etc/rc"
cp /etc/rc /etc/rc.bak cp /etc/rc /etc/rc.bak
tail -n +4 /etc/rc.bak > /etc/rc tail -n +4 /etc/rc.bak > /etc/rc
......
...@@ -105,6 +105,11 @@ ...@@ -105,6 +105,11 @@
/usr/local/etc/rc.ipfw.postload /usr/local/etc/rc.ipfw.postload
/usr/local/etc/rc.kill_states /usr/local/etc/rc.kill_states
/usr/local/etc/rc.linkup /usr/local/etc/rc.linkup
/usr/local/etc/rc.loader
/usr/local/etc/rc.loader.d/00-banner
/usr/local/etc/rc.loader.d/20-brand
/usr/local/etc/rc.loader.d/20-misc
/usr/local/etc/rc.loader.d/20-modules
/usr/local/etc/rc.newipsecdns /usr/local/etc/rc.newipsecdns
/usr/local/etc/rc.newroutedns /usr/local/etc/rc.newroutedns
/usr/local/etc/rc.newwanip /usr/local/etc/rc.newwanip
......
...@@ -1836,57 +1836,6 @@ function get_possible_traffic_source_addresses($include_ipv6_link_local=false) { ...@@ -1836,57 +1836,6 @@ function get_possible_traffic_source_addresses($include_ipv6_link_local=false) {
return $sourceips; return $sourceips;
} }
function load_kernel_module()
{
$mods = array(
'carp',
'if_bridge',
/*
* The netgraph(4) framework is loaded here
* for backwards compat with the pre-16.7
* kernel configuration that compiled all of
* these modules into the kernel. This list
* needs further pruning and probing, it's
* possible we do not need frame relay anymore.
*/
'netgraph',
'ng_UI',
'ng_async',
'ng_bpf',
'ng_bridge',
'ng_car',
'ng_cisco',
'ng_deflate',
'ng_echo',
'ng_eiface',
'ng_ether',
'ng_frame_relay',
'ng_hole',
'ng_iface',
'ng_ksocket',
'ng_l2tp',
'ng_lmi',
'ng_mppc',
'ng_one2many',
'ng_pipe',
'ng_ppp',
'ng_pppoe',
'ng_pptpgre',
'ng_pred1',
'ng_rfc1490',
'ng_socket',
'ng_tcpmss',
'ng_tee',
'ng_tty',
'ng_vjc',
'ng_vlan',
);
foreach ($mods as $mod) {
mwexecf('/sbin/kldload %s', $mod);
}
}
function load_crypto_module() function load_crypto_module()
{ {
global $config; global $config;
...@@ -1946,9 +1895,7 @@ function system_console_configure() ...@@ -1946,9 +1895,7 @@ function system_console_configure()
// ** console settings in /boot/loader.conf // ** console settings in /boot/loader.conf
$new_boot_config = array(); $new_boot_config = array();
$new_boot_config['comconsole_speed'] = null; $new_boot_config['comconsole_speed'] = null;
$new_boot_config['autoboot_delay'] = '"3"';
$new_boot_config['boot_multicons'] = null; $new_boot_config['boot_multicons'] = null;
$new_boot_config['hw.usb.no_pf'] = '"1"';
$new_boot_config['boot_serial'] = null; $new_boot_config['boot_serial'] = null;
$new_boot_config['console'] = null; $new_boot_config['console'] = null;
...@@ -1972,19 +1919,26 @@ function system_console_configure() ...@@ -1972,19 +1919,26 @@ function system_console_configure()
} }
} }
$new_loader_conf = ""; $new_loader_conf = '';
// construct OPNsense config for /boot/loader.conf
foreach ($new_boot_config as $param => $value) { /* reload static values from rc.loader.d */
if (!empty($value)) { mwexecf('/usr/local/etc/rc.loader');
$new_loader_conf .= "{$param}={$value}\n";
} /* copy non-matched settings already there */
}
// copy non matched settings in /boot/loader.conf
foreach (explode("\n", @file_get_contents('/boot/loader.conf')) as $line) { foreach (explode("\n", @file_get_contents('/boot/loader.conf')) as $line) {
if (!empty($line) && !array_key_exists(trim(explode('=', $line)[0]), $new_boot_config)) { if (!empty($line) && !array_key_exists(trim(explode('=', $line)[0]), $new_boot_config)) {
$new_loader_conf .= $line . "\n"; $new_loader_conf .= $line . "\n";
} }
} }
/* add our console options on top now */
foreach ($new_boot_config as $param => $value) {
if (!empty($value)) {
$new_loader_conf .= "{$param}={$value}\n";
}
}
/* write merged file back to target location */
@file_put_contents('/boot/loader.conf', $new_loader_conf); @file_put_contents('/boot/loader.conf', $new_loader_conf);
// ** setup /etc/ttys // ** setup /etc/ttys
......
...@@ -109,9 +109,6 @@ if (is_interface_mismatch()) { ...@@ -109,9 +109,6 @@ if (is_interface_mismatch()) {
while (!set_networking_interfaces_ports(true)); while (!set_networking_interfaces_ports(true));
} }
/* load extra modules not in GENERIC */
load_kernel_module();
/* enable optional crypto modules */ /* enable optional crypto modules */
load_crypto_module(); load_crypto_module();
......
...@@ -25,10 +25,22 @@ ...@@ -25,10 +25,22 @@
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE. POSSIBILITY OF SUCH DAMAGE.
*/ */
/* there seems to be a race with unpacking files */
shell_exec('/bin/sync');
/* abort in case of no valid config for image install */
if (!file_exists('/conf/config.xml')) {
exit(0);
}
require_once 'config.inc'; require_once 'config.inc';
require_once 'util.inc'; require_once 'util.inc';
require_once 'system.inc'; require_once 'system.inc';
/* upgrade config before doing anything else */
convert_config(true);
system_firmware_configure(); system_firmware_configure();
system_console_configure();
#!/bin/sh
# Copyright (c) 2016 Franco Fichtner <franco@opnsense.org>
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
#
# 1. Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
#
# 2. Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
#
# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
# SUCH DAMAGE.
# Files are sorted and should adhere to the following
# rule of thumb: "dd-identifier", for core package
# loader.conf chunks should generally use something
# like "20-mycorevars" and for plugin packages rather
# "50-mypluginvars".
#
# It could be useful for the user to order variables
# or set a higher/lower priority in case some
# use case requires a slightly different setup.
LOADERDIR="/usr/local/etc/rc.loader.d"
LOADERCONF="/boot/loader.conf"
: > ${LOADERCONF}
if [ ! -d ${LOADERDIR} ]; then
# no dir no fun
exit 0;
fi
# collect all matching scripts
LOADERCHUNKS=$(find -s ${LOADERDIR} -type f)
for LOADERCHUNK in ${LOADERCHUNKS}; do
# extract loader chunk origin
LOADERCHUNK=${LOADERCHUNK##"${LOADERDIR}/"}
echo "rc.loader: assembling ${LOADERCHUNK#??-}"
cat ${LOADERDIR}/${LOADERCHUNK} >> ${LOADERCONF}
done
exit 0
##############################################################
# This file was auto-generated using the rc.loader facility. #
# In order to deploy a custom change to this installation, #
# please use /boot/loader.conf.local as it is not rewritten. #
##############################################################
loader_brand="opnsense"
loader_logo="hourglass"
loader_menu_title=""
autoboot_delay="3"
hw.usb.no_pf="1"
# Vital modules that are not in FreeBSD's GENERIC
# configuration will be loaded on boot, which makes
# races with individual module's settings impossible.
carp_load="YES"
if_bridge_load="YES"
if_gif_load="YES"
if_gre_load="YES"
if_lagg_load="YES"
if_tap_load="YES"
if_tun_load="YES"
if_vlan_load="YES"
pf_load="YES"
pflog_load="YES"
pfsync_load="YES"
# The netgraph(4) framework is loaded here
# for backwards compat with the pre-16.7
# kernel configuration that compiled all of
# these modules into the kernel. This list
# needs further pruning and probing, it's
# possible we do not need frame relay anymore.
netgraph_load="YES"
ng_UI_load="YES"
ng_async_load="YES"
ng_bpf_load="YES"
ng_bridge_load="YES"
ng_car_load="YES"
ng_cisco_load="YES"
ng_deflate_load="YES"
ng_echo_load="YES"
ng_eiface_load="YES"
ng_ether_load="YES"
ng_frame_relay_load="YES"
ng_hole_load="YES"
ng_iface_load="YES"
ng_ksocket_load="YES"
ng_l2tp_load="YES"
ng_lmi_load="YES"
ng_mppc_load="YES"
ng_one2many_load="YES"
ng_pipe_load="YES"
ng_ppp_load="YES"
ng_pppoe_load="YES"
ng_pptpgre_load="YES"
ng_pred1_load="YES"
ng_rfc1490_load="YES"
ng_socket_load="YES"
ng_tcpmss_load="YES"
ng_tee_load="YES"
ng_tty_load="YES"
ng_vjc_load="YES"
ng_vlan_load="YES"
...@@ -44,8 +44,9 @@ $config = parse_config(); ...@@ -44,8 +44,9 @@ $config = parse_config();
log_error("rc.reload_all: Reloading all configuration settings."); log_error("rc.reload_all: Reloading all configuration settings.");
system_timezone_configure();
system_firmware_configure(); system_firmware_configure();
system_console_configure();
system_timezone_configure();
system_hostname_configure(); system_hostname_configure();
system_hosts_generate(); system_hosts_generate();
services_dhcpleases_configure(); services_dhcpleases_configure();
......
...@@ -12,8 +12,6 @@ if (count($argv) > 1 && is_numeric($argv[1])) { ...@@ -12,8 +12,6 @@ if (count($argv) > 1 && is_numeric($argv[1])) {
sleep($argv[1]); sleep($argv[1]);
} }
system_firmware_configure();
echo 'Restarting webConfigurator...'; echo 'Restarting webConfigurator...';
system_webgui_configure(); system_webgui_configure();
......
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