From 4977452594b4d0e782e6ed508d78ecf65765bb2d Mon Sep 17 00:00:00 2001 From: Franco Fichtner Date: Wed, 29 Jul 2015 12:10:21 +0200 Subject: [PATCH] system: always rewrite from the default file As an added benefit, (default) will now always revert back to the actual default from the sample configuration, which is exactly how it should be. --- +PRE_INSTALL | 2 -- Makefile | 2 +- src/etc/inc/system.inc | 53 ++++++++++++++++++++++++++++++ src/etc/rc.bootup | 3 ++ src/etc/rc.reload_all | 66 ++++++++++---------------------------- src/www/system_general.php | 33 +------------------ 6 files changed, 75 insertions(+), 84 deletions(-) delete mode 100644 +PRE_INSTALL diff --git a/+PRE_INSTALL b/+PRE_INSTALL deleted file mode 100644 index a65c8af0c..000000000 --- a/+PRE_INSTALL +++ /dev/null @@ -1,2 +0,0 @@ -echo "Removing previous package configuration" -rm -f /usr/local/etc/pkg/repos/origin.conf diff --git a/Makefile b/Makefile index 04ccfaac7..aebb44b95 100644 --- a/Makefile +++ b/Makefile @@ -139,7 +139,7 @@ depends: force scripts: force @mkdir -p ${DESTDIR} - @cp -v -- +PRE_DEINSTALL +PRE_INSTALL +POST_INSTALL ${DESTDIR} + @cp -v -- +PRE_DEINSTALL +POST_INSTALL ${DESTDIR} @sed -i '' -e "s/%%CORE_COMMIT%%/${CORE_COMMIT}/g" \ ${DESTDIR}/+POST_INSTALL diff --git a/src/etc/inc/system.inc b/src/etc/inc/system.inc index 00345b90c..fa6e82b82 100644 --- a/src/etc/inc/system.inc +++ b/src/etc/inc/system.inc @@ -187,6 +187,34 @@ function get_country_codes() return $dn_cc; } +function get_firmware_mirrors() +{ + $mirrors = array(); + + $mirrors['default'] = '(default)'; + $mirrors['https://opnsense.c0urier.net'] = 'c0urier.net (Lund, SE)'; + $mirrors['https://fleximus.org/mirror/opnsense'] = 'Fleximus (Roubaix, FR)'; + $mirrors['http://mirror.ams1.nl.leaseweb.net/opnsense'] = 'LeaseWeb (Amsterdam, NL)'; + $mirrors['http://mirror.fra10.de.leaseweb.net/opnsense'] = 'LeaseWeb (Frankfurt, DE)'; + $mirrors['http://mirror.sfo12.us.leaseweb.net/opnsense'] = 'LeaseWeb (San Francisco, US)'; + $mirrors['http://mirror.wdc1.us.leaseweb.net/opnsense'] = 'LeaseWeb (Washington, D.C., US)'; + $mirrors['http://mirrors.nycbug.org/pub/opnsense'] = 'NYC*BUG (New York, US)'; + $mirrors['http://pkg.opnsense.org'] = 'OPNsense (Amsterdam, NL)'; + + return $mirrors; +} + +function get_firmware_flavours() +{ + $flavours = array(); + + $flavours['default'] = '(default)'; + $flavours['libressl'] = 'LibreSSL'; + $flavours['latest'] = 'OpenSSL'; + + return $flavours; +} + function get_zoneinfo() { return timezone_identifiers_list(DateTimeZone::ALL ^ DateTimeZone::UTC); @@ -1297,6 +1325,31 @@ EOD; } +function system_firmware_configure() +{ + global $config; + + /* rewrite the config via the defaults */ + $origin_conf = '/usr/local/etc/pkg/repos/origin.conf'; + copy("${origin_conf}.sample", $origin_conf); + + if (isset($config['system']['firmware']['mirror'])) { + /* XXX create a proper backend call */ + mwexecf( + '/usr/local/sbin/opnsense-update -sm %s', + str_replace('/', '\/', $config['system']['firmware']['mirror']) + ); + } + + if (isset($config['system']['firmware']['flavour'])) { + /* XXX create a proper backend call */ + mwexecf( + '/usr/local/sbin/opnsense-update -sn %s', + str_replace('/', '\/', $config['system']['firmware']['flavour']) + ); + } +} + function system_timezone_configure() { global $config; diff --git a/src/etc/rc.bootup b/src/etc/rc.bootup index 3aa404a39..2e23bb642 100755 --- a/src/etc/rc.bootup +++ b/src/etc/rc.bootup @@ -196,6 +196,9 @@ load_thermal_hardware(); /* set up our timezone */ system_timezone_configure(); +/* set up firmware configuration */ +system_firmware_configure(); + /* set up our hostname */ system_hostname_configure(); diff --git a/src/etc/rc.reload_all b/src/etc/rc.reload_all index d7b5a60fe..f10b72ac0 100755 --- a/src/etc/rc.reload_all +++ b/src/etc/rc.reload_all @@ -39,57 +39,25 @@ require_once("pfsense-utils.inc"); require_once("services.inc"); require_once("unbound.inc"); -/****f* legacy/reload_all_sync - * NAME - * reload_all - reload all settings - * * INPUTS - * none - * RESULT - * none - ******/ -function reload_all_sync() -{ - global $config; - - /* parse config.xml again */ - $config = parse_config(); - - /* set up our timezone */ - system_timezone_configure(); - - /* set up our hostname */ - system_hostname_configure(); - - /* make hosts file */ - system_hosts_generate(); - - /* generate resolv.conf */ - system_resolvconf_generate(); - - /* enable routing */ - system_routing_enable(); - - /* set up interfaces */ - interfaces_configure(); - - /* start dyndns service */ - services_dyndns_configure(); - - /* configure cron service */ - configure_cron(); - - /* start the NTP client */ - system_ntp_configure(); - - /* restart sshd */ - mwexec_bg('/usr/local/etc/rc.sshd'); - - /* restart webConfigurator if needed */ - mwexec_bg('/usr/local/etc/rc.restart_webgui'); -} +global $config; +$config = parse_config(); log_error("rc.reload_all: Reloading all configuration settings."); -reload_all_sync(); + +system_timezone_configure(); +system_firmware_configure(); +system_hostname_configure(); +system_hosts_generate(); +system_resolvconf_generate(); +system_routing_enable(); +interfaces_configure(); +services_dyndns_configure(); +configure_cron(); +system_ntp_configure(); +mwexec_bg('/usr/local/etc/rc.sshd'); +mwexec_bg('/usr/local/etc/rc.restart_webgui'); + log_error("rc.reload_all: Reloading filter configuration."); + filter_configure_sync(); diff --git a/src/www/system_general.php b/src/www/system_general.php index aa7858369..0aab56953 100644 --- a/src/www/system_general.php +++ b/src/www/system_general.php @@ -50,34 +50,6 @@ function get_locale_list() return $locales; } -function get_firmware_mirrors() -{ - $mirrors = array(); - - $mirrors['default'] = '(default)'; - $mirrors['https://opnsense.c0urier.net'] = 'c0urier.net (Lund, SE)'; - $mirrors['https://fleximus.org/mirror/opnsense'] = 'Fleximus (Roubaix, FR)'; - $mirrors['http://mirror.ams1.nl.leaseweb.net/opnsense'] = 'LeaseWeb (Amsterdam, NL)'; - $mirrors['http://mirror.fra10.de.leaseweb.net/opnsense'] = 'LeaseWeb (Frankfurt, DE)'; - $mirrors['http://mirror.sfo12.us.leaseweb.net/opnsense'] = 'LeaseWeb (San Francisco, US)'; - $mirrors['http://mirror.wdc1.us.leaseweb.net/opnsense'] = 'LeaseWeb (Washington, D.C., US)'; - $mirrors['http://mirrors.nycbug.org/pub/opnsense'] = 'NYC*BUG (New York, US)'; - $mirrors['http://pkg.opnsense.org'] = 'OPNsense (Amsterdam, NL)'; - - return $mirrors; -} - -function get_firmware_flavours() -{ - $flavours = array(); - - $flavours['default'] = '(default)'; - $flavours['libressl'] = 'LibreSSL'; - $flavours['latest'] = 'OpenSSL'; - - return $flavours; -} - $pconfig['hostname'] = $config['system']['hostname']; $pconfig['domain'] = $config['system']['domain']; if (isset($config['system']['dnsserver'])) { @@ -253,16 +225,12 @@ if ($_POST) { /* default does not set anything for backwards compat */ unset($config['system']['firmware']['mirror']); } else { - /* XXX create a proper backend call */ - mwexecf('/usr/local/sbin/opnsense-update -sm %s', str_replace('/', '\/', $_POST['mirror'])); $config['system']['firmware']['mirror'] = $_POST['mirror']; } if ($_POST['flavour'] == 'default' && isset($config['system']['firmware']['flavour'])) { /* default does not set anything for backwards compat */ unset($config['system']['firmware']['flavour']); } else { - /* XXX create a proper backend call */ - mwexecf('/usr/local/sbin/opnsense-update -sn %s', str_replace('/', '\/', $_POST['flavour'])); $config['system']['firmware']['flavour'] = $_POST['flavour']; } @@ -347,6 +315,7 @@ if ($_POST) { elseif (isset($config['unbound']['enable'])) $retval |= services_unbound_configure(); $retval |= system_timezone_configure(); + $retval |= system_firmware_configure(); $retval |= system_ntp_configure(); if ($olddnsallowoverride != $config['system']['dnsallowoverride']) {