Commit c7f253ff authored by Franco Fichtner's avatar Franco Fichtner

src: deprecate /cf/conf in favour of /conf

It's been confusing to say the least, resulting in multiple
misuses throughout the code.  The idea was that /cf pointed
to a read-write root, while / pointed to read-only root.
For non-embedded images this was emulated by linking
/conf -> /cf/conf, which, is a bit questionable because now
you can write from /conf as well and don't have to use /cf/conf
at all.

A couple of lines are left in /usr/local/etc/rc which need to
be reviewed so that migration paths are safe for all types
of firmware upgrades.
parent ba798a7f
#!/bin/sh #!/bin/sh
vi /cf/conf/config.xml vi /conf/config.xml
rm /tmp/config.cache rm /tmp/config.cache
...@@ -62,8 +62,8 @@ if(file_exists("/debugging")) { ...@@ -62,8 +62,8 @@ if(file_exists("/debugging")) {
$g['debug'] = true; $g['debug'] = true;
} }
if(file_exists("/var/run/booting") && file_exists("/cf/conf/config.xml")) { if(file_exists("/var/run/booting") && file_exists("/conf/config.xml")) {
$config_contents = file_get_contents("/cf/conf/config.xml"); $config_contents = file_get_contents("/conf/config.xml");
if(stristr($config_contents, "<m0n0wall>") == true) { if(stristr($config_contents, "<m0n0wall>") == true) {
/* user has just upgraded to m0n0wall, replace root xml tags */ /* user has just upgraded to m0n0wall, replace root xml tags */
log_error(gettext("Upgrading m0n0wall configuration to pfSense... ")); log_error(gettext("Upgrading m0n0wall configuration to pfSense... "));
...@@ -71,7 +71,7 @@ if(file_exists("/var/run/booting") && file_exists("/cf/conf/config.xml")) { ...@@ -71,7 +71,7 @@ if(file_exists("/var/run/booting") && file_exists("/cf/conf/config.xml")) {
if (!config_validate('/conf/config.xml')) if (!config_validate('/conf/config.xml'))
log_error(gettext("ERROR! Could not convert m0n0wall -> pfsense in config.xml")); log_error(gettext("ERROR! Could not convert m0n0wall -> pfsense in config.xml"));
conf_mount_rw(); conf_mount_rw();
$fd = fopen("/cf/conf/config.xml", "w"); $fd = fopen("/conf/config.xml", "w");
fwrite($fd, $config_contents); fwrite($fd, $config_contents);
fclose($fd); fclose($fd);
conf_mount_ro(); conf_mount_ro();
...@@ -79,7 +79,7 @@ if(file_exists("/var/run/booting") && file_exists("/cf/conf/config.xml")) { ...@@ -79,7 +79,7 @@ if(file_exists("/var/run/booting") && file_exists("/cf/conf/config.xml")) {
} }
/* if our config file exists bail out, we're already set. */ /* if our config file exists bail out, we're already set. */
else if (file_exists("/var/run/booting") && !file_exists('/cf/conf/config.xml')) { else if (file_exists("/var/run/booting") && !file_exists('/conf/config.xml')) {
/* find the device where config.xml resides and write out an fstab */ /* find the device where config.xml resides and write out an fstab */
unset($cfgdevice); unset($cfgdevice);
/* check if there's already an fstab (NFS booting?) */ /* check if there's already an fstab (NFS booting?) */
...@@ -108,7 +108,7 @@ else if (file_exists("/var/run/booting") && !file_exists('/cf/conf/config.xml')) ...@@ -108,7 +108,7 @@ else if (file_exists("/var/run/booting") && !file_exists('/cf/conf/config.xml'))
if (strstr($mountdisk, "md")) if (strstr($mountdisk, "md"))
continue; continue;
if (mwexec("/sbin/mount -r /dev/{$mountdisk}a {$g['cf_path']}") == 0) { if (mwexec("/sbin/mount -r /dev/{$mountdisk}a {$g['cf_path']}") == 0) {
if (file_exists('/cf/conf/config.xml')) { if (file_exists('/conf/config.xml')) {
/* found it */ /* found it */
$cfgdevice = $mountdisk; $cfgdevice = $mountdisk;
$cfgpartition = $cfgdevice . "a"; $cfgpartition = $cfgdevice . "a";
...@@ -122,7 +122,7 @@ else if (file_exists("/var/run/booting") && !file_exists('/cf/conf/config.xml')) ...@@ -122,7 +122,7 @@ else if (file_exists("/var/run/booting") && !file_exists('/cf/conf/config.xml'))
break; break;
} }
if (mwexec("/sbin/mount -r /dev/{$mountdisk}d {$g['cf_path']}") == 0) { if (mwexec("/sbin/mount -r /dev/{$mountdisk}d {$g['cf_path']}") == 0) {
if (file_exists('/cf/conf/config.xml')) { if (file_exists('/conf/config.xml')) {
/* found it */ /* found it */
$cfgdevice = $mountdisk; $cfgdevice = $mountdisk;
$cfgpartition = $cfgdevice . "d"; $cfgpartition = $cfgdevice . "d";
...@@ -142,7 +142,7 @@ else if (file_exists("/var/run/booting") && !file_exists('/cf/conf/config.xml')) ...@@ -142,7 +142,7 @@ else if (file_exists("/var/run/booting") && !file_exists('/cf/conf/config.xml'))
if($last_backup) { if($last_backup) {
log_error(gettext("No config.xml found, attempting last known config restore.")); log_error(gettext("No config.xml found, attempting last known config restore."));
file_notice("config.xml", gettext("No config.xml found, attempting last known config restore."), "pfSenseConfigurator", ""); file_notice("config.xml", gettext("No config.xml found, attempting last known config restore."), "pfSenseConfigurator", "");
restore_backup("/cf/conf/backup/{$last_backup}"); restore_backup("/conf/backup/{$last_backup}");
} else { } else {
log_error(gettext("No config.xml or config backups found, resetting to factory defaults.")); log_error(gettext("No config.xml or config backups found, resetting to factory defaults."));
restore_backup('/usr/local/etc/config.xml'); restore_backup('/usr/local/etc/config.xml');
......
...@@ -122,7 +122,7 @@ function parse_config($parse = false) ...@@ -122,7 +122,7 @@ function parse_config($parse = false)
file_notice("config.xml", "No config.xml found, attempting last known config restore.", "pfSenseConfigurator", ""); file_notice("config.xml", "No config.xml found, attempting last known config restore.", "pfSenseConfigurator", "");
$last_backup = discover_last_backup(); $last_backup = discover_last_backup();
if ($last_backup) if ($last_backup)
restore_backup("/cf/conf/backup/{$last_backup}"); restore_backup("/conf/backup/{$last_backup}");
else { else {
log_error(gettext("Could not restore config.xml.")); log_error(gettext("Could not restore config.xml."));
unlock($lockkey); unlock($lockkey);
...@@ -133,7 +133,7 @@ function parse_config($parse = false) ...@@ -133,7 +133,7 @@ function parse_config($parse = false)
if($config == -1) { if($config == -1) {
$last_backup = discover_last_backup(); $last_backup = discover_last_backup();
if ($last_backup) if ($last_backup)
restore_backup("/cf/conf/backup/{$last_backup}"); restore_backup("/conf/backup/{$last_backup}");
else { else {
log_error(gettext("Could not restore config.xml.")); log_error(gettext("Could not restore config.xml."));
unlock($lockkey); unlock($lockkey);
...@@ -177,7 +177,7 @@ function generate_config_cache($config) { ...@@ -177,7 +177,7 @@ function generate_config_cache($config) {
} }
function discover_last_backup() { function discover_last_backup() {
$backups = glob('/cf/conf/backup/*.xml'); $backups = glob('/conf/backup/*.xml');
$last_backup = ""; $last_backup = "";
$last_mtime = 0; $last_mtime = 0;
foreach($backups as $backup) { foreach($backups as $backup) {
...@@ -196,7 +196,7 @@ function restore_backup($file) { ...@@ -196,7 +196,7 @@ function restore_backup($file) {
if (file_exists($file)) { if (file_exists($file)) {
conf_mount_rw(); conf_mount_rw();
unlink_if_exists("{$g['tmp_path']}/config.cache"); unlink_if_exists("{$g['tmp_path']}/config.cache");
copy("$file","/cf/conf/config.xml"); copy("$file","/conf/config.xml");
disable_security_checks(); disable_security_checks();
log_error(sprintf(gettext('%1$s is restoring the configuration %2$s'), $g['product_name'], $file)); log_error(sprintf(gettext('%1$s is restoring the configuration %2$s'), $g['product_name'], $file));
file_notice("config.xml", sprintf(gettext('%1$s is restoring the configuration %2$s'), $g['product_name'], $file), "pfSenseConfigurator", ""); file_notice("config.xml", sprintf(gettext('%1$s is restoring the configuration %2$s'), $g['product_name'], $file), "pfSenseConfigurator", "");
...@@ -234,7 +234,7 @@ function parse_config_bootup() ...@@ -234,7 +234,7 @@ function parse_config_bootup()
if($last_backup) { if($last_backup) {
log_error("No config.xml found, attempting last known config restore."); log_error("No config.xml found, attempting last known config restore.");
file_notice("config.xml", gettext("No config.xml found, attempting last known config restore."), "pfSenseConfigurator", ""); file_notice("config.xml", gettext("No config.xml found, attempting last known config restore."), "pfSenseConfigurator", "");
restore_backup("/cf/conf/backup/{$last_backup}"); restore_backup("/conf/backup/{$last_backup}");
} }
if (!file_exists($config_xml)) { if (!file_exists($config_xml)) {
echo sprintf(gettext("XML configuration file not found. %s cannot continue booting."), $g['product_name']) . "\n"; echo sprintf(gettext("XML configuration file not found. %s cannot continue booting."), $g['product_name']) . "\n";
...@@ -509,10 +509,10 @@ function write_config($desc = 'Unknown', $backup = true) ...@@ -509,10 +509,10 @@ function write_config($desc = 'Unknown', $backup = true)
$xmlconfig = dump_xml_config($config, $g['xml_rootobj']); $xmlconfig = dump_xml_config($config, $g['xml_rootobj']);
/* write new configuration */ /* write new configuration */
if (!safe_write_file('/cf/conf/config.xml', $xmlconfig, false)) { if (!safe_write_file('/conf/config.xml', $xmlconfig, false)) {
log_error(gettext("WARNING: Config contents could not be save. Could not open file!")); log_error(gettext("WARNING: Config contents could not be save. Could not open file!"));
unlock($lockkey); unlock($lockkey);
file_notice('config.xml', sprintf("%s\n", gettext('Unable to open /cf/conf/config.xml for writing in write_config()'))); file_notice('config.xml', sprintf("%s\n", gettext('Unable to open /conf/config.xml for writing in write_config()')));
return -1; return -1;
} }
...@@ -525,7 +525,7 @@ function write_config($desc = 'Unknown', $backup = true) ...@@ -525,7 +525,7 @@ function write_config($desc = 'Unknown', $backup = true)
copy($config_xml, $config_xml . '.bad'); copy($config_xml, $config_xml . '.bad');
$last_backup = discover_last_backup(); $last_backup = discover_last_backup();
if ($last_backup) { if ($last_backup) {
restore_backup("/cf/conf/backup/{$last_backup}"); restore_backup("/conf/backup/{$last_backup}");
$config = parse_xml_config($config_xml, $g['xml_rootobj']); $config = parse_xml_config($config_xml, $g['xml_rootobj']);
if (file_exists("/var/run/booting")) { if (file_exists("/var/run/booting")) {
echo "\n\n ************** WARNING **************"; echo "\n\n ************** WARNING **************";
...@@ -570,7 +570,7 @@ function reset_factory_defaults($lock = false) ...@@ -570,7 +570,7 @@ function reset_factory_defaults($lock = false)
$lockkey = lock('config', LOCK_EX); $lockkey = lock('config', LOCK_EX);
/* create conf directory, if necessary */ /* create conf directory, if necessary */
safe_mkdir('/cf/conf'); safe_mkdir('/conf');
/* clear out /conf */ /* clear out /conf */
$dh = opendir('/conf'); $dh = opendir('/conf');
...@@ -609,7 +609,7 @@ function config_restore($conffile) { ...@@ -609,7 +609,7 @@ function config_restore($conffile) {
$lockkey = lock('config', LOCK_EX); $lockkey = lock('config', LOCK_EX);
unlink_if_exists("{$g['tmp_path']}/config.cache"); unlink_if_exists("{$g['tmp_path']}/config.cache");
copy($conffile, '/cf/conf/config.xml'); copy($conffile, '/conf/config.xml');
disable_security_checks(); disable_security_checks();
...@@ -726,7 +726,7 @@ function cleanup_backupcache($lock = false) { ...@@ -726,7 +726,7 @@ function cleanup_backupcache($lock = false) {
$baktimes = array(); $baktimes = array();
} }
$newbaks = array(); $newbaks = array();
$bakfiles = glob('/cf/conf/backup/config-*'); $bakfiles = glob('/conf/backup/config-*');
$tocache = array(); $tocache = array();
foreach($bakfiles as $backup) { // Check for backups in the directory not represented in the cache. foreach($bakfiles as $backup) { // Check for backups in the directory not represented in the cache.
...@@ -772,7 +772,7 @@ function cleanup_backupcache($lock = false) { ...@@ -772,7 +772,7 @@ function cleanup_backupcache($lock = false) {
} }
$tocache = $newcache; $tocache = $newcache;
} }
$bakout = fopen('/cf/conf/backup/backup.cache', 'w'); $bakout = fopen('/conf/backup/backup.cache', 'w');
fwrite($bakout, serialize($tocache)); fwrite($bakout, serialize($tocache));
fclose($bakout); fclose($bakout);
conf_mount_ro(); conf_mount_ro();
...@@ -783,8 +783,8 @@ function cleanup_backupcache($lock = false) { ...@@ -783,8 +783,8 @@ function cleanup_backupcache($lock = false) {
function get_backups() function get_backups()
{ {
if (file_exists('/cf/conf/backup/backup.cache')) { if (file_exists('/conf/backup/backup.cache')) {
$confvers = unserialize(file_get_contents('/cf/conf/backup/backup.cache')); $confvers = unserialize(file_get_contents('/conf/backup/backup.cache'));
$bakvers = array_keys($confvers); $bakvers = array_keys($confvers);
$toreturn = array(); $toreturn = array();
sort($bakvers); sort($bakvers);
...@@ -803,7 +803,7 @@ function backup_config() ...@@ -803,7 +803,7 @@ function backup_config()
conf_mount_rw(); conf_mount_rw();
/* Create backup directory if needed */ /* Create backup directory if needed */
safe_mkdir('/cf/conf/backup'); safe_mkdir('/conf/backup');
if ($config['revision']['time'] == '') { if ($config['revision']['time'] == '') {
$baktime = 0; $baktime = 0;
...@@ -818,17 +818,17 @@ function backup_config() ...@@ -818,17 +818,17 @@ function backup_config()
} }
$bakver = ($config['version'] == '') ? '?' : $config['version']; $bakver = ($config['version'] == '') ? '?' : $config['version'];
$bakfilename = '/cf/conf/backup/config-' . $baktime . '.xml'; $bakfilename = '/conf/backup/config-' . $baktime . '.xml';
copy('/cf/conf/config.xml', $bakfilename); copy('/conf/config.xml', $bakfilename);
if (file_exists('/cf/conf/backup/backup.cache')) { if (file_exists('/conf/backup/backup.cache')) {
$backupcache = unserialize(file_get_contents('/cf/conf/backup/backup.cache')); $backupcache = unserialize(file_get_contents('/conf/backup/backup.cache'));
} else { } else {
$backupcache = array(); $backupcache = array();
} }
$backupcache[$baktime] = array('description' => $bakdesc, 'version' => $bakver, 'filesize' => filesize($bakfilename)); $backupcache[$baktime] = array('description' => $bakdesc, 'version' => $bakver, 'filesize' => filesize($bakfilename));
$bakout = fopen('/cf/conf/backup/backup.cache', 'w'); $bakout = fopen('/conf/backup/backup.cache', 'w');
fwrite($bakout, serialize($backupcache)); fwrite($bakout, serialize($backupcache));
fclose($bakout); fclose($bakout);
......
...@@ -50,11 +50,11 @@ function restore_rrd() ...@@ -50,11 +50,11 @@ function restore_rrd()
$rrdrestore = ""; $rrdrestore = "";
$rrdreturn = ""; $rrdreturn = "";
if (file_exists('/cf/conf/rrd.tgz')) { if (file_exists('/conf/rrd.tgz')) {
foreach (glob("{$rrddbpath}/*.xml") as $xml_file) { foreach (glob("{$rrddbpath}/*.xml") as $xml_file) {
@unlink($xml_file); @unlink($xml_file);
} }
$_gb = exec('cd /;LANG=C /usr/bin/tar -xzf /cf/conf/rrd.tgz 2>&1', $rrdrestore, $rrdreturn); $_gb = exec('cd /;LANG=C /usr/bin/tar -xzf /conf/rrd.tgz 2>&1', $rrdrestore, $rrdreturn);
$rrdrestore = implode(" ", $rrdrestore); $rrdrestore = implode(" ", $rrdrestore);
if($rrdreturn != 0) { if($rrdreturn != 0) {
log_error("RRD restore failed exited with $rrdreturn, the error is: $rrdrestore\n"); log_error("RRD restore failed exited with $rrdreturn, the error is: $rrdrestore\n");
...@@ -77,7 +77,7 @@ function restore_rrd() ...@@ -77,7 +77,7 @@ function restore_rrd()
} }
/* If this backup is still there on a full install, but we aren't going to use ram disks, remove the archive since this is a transition. */ /* If this backup is still there on a full install, but we aren't going to use ram disks, remove the archive since this is a transition. */
if (($g['platform'] == "pfSense") && !isset($config['system']['use_mfs_tmpvar'])) { if (($g['platform'] == "pfSense") && !isset($config['system']['use_mfs_tmpvar'])) {
unlink_if_exists('/cf/conf/rrd.tgz'); unlink_if_exists('/conf/rrd.tgz');
} }
return true; return true;
} }
......
...@@ -346,10 +346,10 @@ function services_dhcpdv4_configure() ...@@ -346,10 +346,10 @@ function services_dhcpdv4_configure()
if (file_exists("/var/run/booting")) { if (file_exists("/var/run/booting")) {
/* restore the leases, if we have them */ /* restore the leases, if we have them */
if (file_exists('/cf/conf/dhcpleases.tgz')) { if (file_exists('/conf/dhcpleases.tgz')) {
$dhcprestore = ''; $dhcprestore = '';
$dhcpreturn = ''; $dhcpreturn = '';
exec('cd /;LANG=C /usr/bin/tar -xzf /cf/conf/dhcpleases.tgz 2>&1', $dhcprestore, $dhcpreturn); exec('cd /;LANG=C /usr/bin/tar -xzf /conf/dhcpleases.tgz 2>&1', $dhcprestore, $dhcpreturn);
$dhcprestore = implode(' ', $dhcprestore); $dhcprestore = implode(' ', $dhcprestore);
if($dhcpreturn <> 0) { if($dhcpreturn <> 0) {
log_error(sprintf(gettext('DHCP leases restore failed exited with %1$s, the error is: %2$s%3$s'), $dhcpreturn, $dhcprestore, "\n")); log_error(sprintf(gettext('DHCP leases restore failed exited with %1$s, the error is: %2$s%3$s'), $dhcpreturn, $dhcprestore, "\n"));
...@@ -357,7 +357,7 @@ function services_dhcpdv4_configure() ...@@ -357,7 +357,7 @@ function services_dhcpdv4_configure()
} }
/* If this backup is still there on a full install, but we aren't going to use ram disks, remove the archive since this is a transition. */ /* If this backup is still there on a full install, but we aren't going to use ram disks, remove the archive since this is a transition. */
if (($g['platform'] == "pfSense") && !isset($config['system']['use_mfs_tmpvar'])) { if (($g['platform'] == "pfSense") && !isset($config['system']['use_mfs_tmpvar'])) {
unlink_if_exists('/cf/conf/dhcpleases.tgz'); unlink_if_exists('/conf/dhcpleases.tgz');
} }
} }
...@@ -974,10 +974,10 @@ function services_dhcpdv6_configure($blacklist = array()) ...@@ -974,10 +974,10 @@ function services_dhcpdv6_configure($blacklist = array())
if (file_exists("/var/run/booting")) { if (file_exists("/var/run/booting")) {
if ($g['platform'] != "pfSense") { if ($g['platform'] != "pfSense") {
/* restore the leases, if we have them */ /* restore the leases, if we have them */
if (file_exists('/cf/conf/dhcp6leases.tgz')) { if (file_exists('/conf/dhcp6leases.tgz')) {
$dhcprestore = ''; $dhcprestore = '';
$dhcpreturn = ''; $dhcpreturn = '';
exec('cd /;LANG=C /usr/bin/tar -xzf /cf/conf/dhcp6leases.tgz 2>&1', $dhcprestore, $dhcpreturn); exec('cd /;LANG=C /usr/bin/tar -xzf /conf/dhcp6leases.tgz 2>&1', $dhcprestore, $dhcpreturn);
$dhcprestore = implode(' ', $dhcprestore); $dhcprestore = implode(' ', $dhcprestore);
if($dhcpreturn <> 0) { if($dhcpreturn <> 0) {
log_error("DHCP leases v6 restore failed exited with $dhcpreturn, the error is: $dhcprestore\n"); log_error("DHCP leases v6 restore failed exited with $dhcpreturn, the error is: $dhcprestore\n");
...@@ -987,7 +987,7 @@ function services_dhcpdv6_configure($blacklist = array()) ...@@ -987,7 +987,7 @@ function services_dhcpdv6_configure($blacklist = array())
} }
/* If this backup is still there on a full install, but we aren't going to use ram disks, remove the archive since this is a transition. */ /* If this backup is still there on a full install, but we aren't going to use ram disks, remove the archive since this is a transition. */
if (($g['platform'] == "pfSense") && !isset($config['system']['use_mfs_tmpvar'])) { if (($g['platform'] == "pfSense") && !isset($config['system']['use_mfs_tmpvar'])) {
unlink_if_exists('/cf/conf/dhcp6leases.tgz'); unlink_if_exists('/conf/dhcp6leases.tgz');
} }
} }
......
...@@ -1913,7 +1913,7 @@ function upgrade_054_to_055() { ...@@ -1913,7 +1913,7 @@ function upgrade_054_to_055() {
/* restore the databases, if we have one */ /* restore the databases, if we have one */
if (restore_rrd()) { if (restore_rrd()) {
/* Make sure to move the rrd backup out of the way. We will make a new one after converting. */ /* Make sure to move the rrd backup out of the way. We will make a new one after converting. */
rename('/cf/conf/rrd.tgz', '/cf/conf/backup'); rename('/conf/rrd.tgz', '/conf/backup/rrd.tgz');
} }
} }
...@@ -2031,7 +2031,7 @@ function upgrade_054_to_055() { ...@@ -2031,7 +2031,7 @@ function upgrade_054_to_055() {
enable_rrd_graphing(); enable_rrd_graphing();
/* Let's save the RRD graphs after we run enable RRD graphing */ /* Let's save the RRD graphs after we run enable RRD graphing */
/* The function will restore the rrd.tgz so we will save it after */ /* The function will restore the rrd.tgz so we will save it after */
exec("cd /; LANG=C NO_REMOUNT=1 RRDDBPATH='{$rrddbpath}' CF_CONF_PATH='/cf/conf' /usr/local/etc/rc.backup_rrd"); exec("cd /; LANG=C NO_REMOUNT=1 RRDDBPATH='{$rrddbpath}' CF_CONF_PATH='/conf' /usr/local/etc/rc.backup_rrd");
unlink_if_exists("{$g['vardb_path']}/rrd/*.xml"); unlink_if_exists("{$g['vardb_path']}/rrd/*.xml");
if (file_exists("/var/run/booting")) if (file_exists("/var/run/booting"))
echo "Updating configuration..."; echo "Updating configuration...";
...@@ -2576,7 +2576,7 @@ function upgrade_080_to_081() { ...@@ -2576,7 +2576,7 @@ function upgrade_080_to_081() {
/* restore the databases, if we have one */ /* restore the databases, if we have one */
if (restore_rrd()) { if (restore_rrd()) {
/* Make sure to move the rrd backup out of the way. We will make a new one after converting. */ /* Make sure to move the rrd backup out of the way. We will make a new one after converting. */
@rename('/cf/conf/rrd.tgz', '/cf/conf/backup/rrd.tgz'); @rename('/conf/rrd.tgz', '/conf/backup/rrd.tgz');
} }
} }
...@@ -2713,7 +2713,7 @@ function upgrade_080_to_081() { ...@@ -2713,7 +2713,7 @@ function upgrade_080_to_081() {
enable_rrd_graphing(); enable_rrd_graphing();
/* Let's save the RRD graphs after we run enable RRD graphing */ /* Let's save the RRD graphs after we run enable RRD graphing */
/* The function will restore the rrd.tgz so we will save it after */ /* The function will restore the rrd.tgz so we will save it after */
exec("cd /; LANG=C NO_REMOUNT=1 RRDDBPATH='{$rrddbpath}' CF_CONF_PATH='/cf/conf' /usr/local/etc/rc.backup_rrd"); exec("cd /; LANG=C NO_REMOUNT=1 RRDDBPATH='{$rrddbpath}' CF_CONF_PATH='/conf' /usr/local/etc/rc.backup_rrd");
if (file_exists("/var/run/booting")) if (file_exists("/var/run/booting"))
echo "Updating configuration..."; echo "Updating configuration...";
foreach($config['filter']['rule'] as & $rule) { foreach($config['filter']['rule'] as & $rule) {
...@@ -3023,7 +3023,7 @@ function upgrade_095_to_096() { ...@@ -3023,7 +3023,7 @@ function upgrade_095_to_096() {
/* restore the databases, if we have one */ /* restore the databases, if we have one */
if (restore_rrd()) { if (restore_rrd()) {
/* Make sure to move the rrd backup out of the way. We will make a new one after converting. */ /* Make sure to move the rrd backup out of the way. We will make a new one after converting. */
rename('/cf/conf/rrd.tgz', '/cf/conf/backup'); rename('/conf/rrd.tgz', '/conf/backup/rrd.tgz');
} }
} }
...@@ -3046,7 +3046,7 @@ function upgrade_095_to_096() { ...@@ -3046,7 +3046,7 @@ function upgrade_095_to_096() {
enable_rrd_graphing(); enable_rrd_graphing();
/* Let's save the RRD graphs after we run enable RRD graphing */ /* Let's save the RRD graphs after we run enable RRD graphing */
/* The function will restore the rrd.tgz so we will save it after */ /* The function will restore the rrd.tgz so we will save it after */
exec("cd /; LANG=C NO_REMOUNT=1 RRDDBPATH='{$rrddbpath}' CF_CONF_PATH='/cf/conf' /usr/local/etc/rc.backup_rrd"); exec("cd /; LANG=C NO_REMOUNT=1 RRDDBPATH='{$rrddbpath}' CF_CONF_PATH='/conf' /usr/local/etc/rc.backup_rrd");
} }
function upgrade_096_to_097() { function upgrade_096_to_097() {
......
...@@ -106,7 +106,7 @@ else ...@@ -106,7 +106,7 @@ else
done done
fi fi
USE_MFS_TMPVAR=`/usr/bin/grep -c use_mfs_tmpvar /cf/conf/config.xml` USE_MFS_TMPVAR=`/usr/bin/grep -c use_mfs_tmpvar /conf/config.xml`
if [ "${PLATFORM}" = "nanobsd" ] || [ ${USE_MFS_TMPVAR} -gt 0 ]; then if [ "${PLATFORM}" = "nanobsd" ] || [ ${USE_MFS_TMPVAR} -gt 0 ]; then
/usr/local/etc/rc.embedded /usr/local/etc/rc.embedded
fi fi
...@@ -258,8 +258,8 @@ if [ ! -d /var/tmp ]; then ...@@ -258,8 +258,8 @@ if [ ! -d /var/tmp ]; then
/bin/mkdir -p /var/tmp /bin/mkdir -p /var/tmp
fi fi
if [ ! -d /cf/conf/backup/ ]; then if [ ! -d /conf/backup/ ]; then
/bin/mkdir -p /cf/conf/backup/ /bin/mkdir -p /conf/backup/
fi fi
set -T set -T
...@@ -273,8 +273,8 @@ trap "echo 'Reboot interrupted'; exit 1" 3 ...@@ -273,8 +273,8 @@ trap "echo 'Reboot interrupted'; exit 1" 3
/bin/chmod 0777 /tmp/uploadbar /bin/chmod 0777 /tmp/uploadbar
echo -n "." echo -n "."
DISABLESYSLOGCLOG=`/usr/bin/grep -c disablesyslogclog /cf/conf/config.xml` DISABLESYSLOGCLOG=`/usr/bin/grep -c disablesyslogclog /conf/config.xml`
ENABLEFIFOLOG=`/usr/bin/grep -c usefifolog /cf/conf/config.xml` ENABLEFIFOLOG=`/usr/bin/grep -c usefifolog /conf/config.xml`
LOG_FILES="system filter dhcpd vpn pptps poes l2tps openvpn portalauth ipsec ppp relayd wireless lighttpd ntpd gateways resolver routing" LOG_FILES="system filter dhcpd vpn pptps poes l2tps openvpn portalauth ipsec ppp relayd wireless lighttpd ntpd gateways resolver routing"
DEFAULT_LOG_FILE_SIZE=`/usr/local/bin/xmllint --xpath 'string(//pfsense/syslog/logfilesize)' /conf/config.xml` DEFAULT_LOG_FILE_SIZE=`/usr/local/bin/xmllint --xpath 'string(//pfsense/syslog/logfilesize)' /conf/config.xml`
...@@ -342,7 +342,7 @@ sleep 1 # give configd some time to load to prevent missing socket ...@@ -342,7 +342,7 @@ sleep 1 # give configd some time to load to prevent missing socket
# let the PHP-based configuration subsystem set up the system now # let the PHP-based configuration subsystem set up the system now
echo -n "Launching the init system..." echo -n "Launching the init system..."
/bin/rm -f /cf/conf/backup/backup.cache /bin/rm -f /conf/backup/backup.cache
/bin/rm -f /root/lighttpd* /bin/rm -f /root/lighttpd*
/usr/bin/touch /var/run/booting /usr/bin/touch /var/run/booting
/usr/local/etc/rc.bootup /usr/local/etc/rc.bootup
......
...@@ -3,6 +3,6 @@ ...@@ -3,6 +3,6 @@
# Save the DHCP lease database to the config path. # Save the DHCP lease database to the config path.
if [ -d "/var/dhcpd/var/db" ]; then if [ -d "/var/dhcpd/var/db" ]; then
/usr/local/etc/rc.conf_mount_rw /usr/local/etc/rc.conf_mount_rw
cd / && tar -czf /cf/conf/dhcpleases.tgz -C / var/dhcpd/var/db/ cd / && tar -czf /conf/dhcpleases.tgz -C / var/dhcpd/var/db/
/usr/local/etc/rc.conf_mount_ro /usr/local/etc/rc.conf_mount_ro
fi fi
#!/bin/sh #!/bin/sh
: ${RRDDBPATH:=/var/db/rrd} : ${RRDDBPATH:=/var/db/rrd}
: ${CF_CONF_PATH:=/cf/conf} : ${CF_CONF_PATH:=/conf}
# Save the rrd databases to the config path. # Save the rrd databases to the config path.
if [ -d "${RRDDBPATH}" ]; then if [ -d "${RRDDBPATH}" ]; then
......
#!/bin/sh #!/bin/sh
# #
# Size of /tmp # Size of /tmp
USE_MFS_TMP_SIZE=`/usr/bin/grep use_mfs_tmp_size /cf/conf/config.xml | /usr/bin/cut -f2 -d'>' | /usr/bin/cut -f1 -d'<'` USE_MFS_TMP_SIZE=`/usr/bin/grep use_mfs_tmp_size /conf/config.xml | /usr/bin/cut -f2 -d'>' | /usr/bin/cut -f1 -d'<'`
if [ ! -z ${USE_MFS_TMP_SIZE} ] && [ ${USE_MFS_TMP_SIZE} -gt 0 ]; then if [ ! -z ${USE_MFS_TMP_SIZE} ] && [ ${USE_MFS_TMP_SIZE} -gt 0 ]; then
tmpsize="${USE_MFS_TMP_SIZE}m" tmpsize="${USE_MFS_TMP_SIZE}m"
else else
...@@ -9,7 +9,7 @@ else ...@@ -9,7 +9,7 @@ else
fi fi
# Size of /var # Size of /var
USE_MFS_VAR_SIZE=`/usr/bin/grep use_mfs_var_size /cf/conf/config.xml | /usr/bin/cut -f2 -d'>' | /usr/bin/cut -f1 -d'<'` USE_MFS_VAR_SIZE=`/usr/bin/grep use_mfs_var_size /conf/config.xml | /usr/bin/cut -f2 -d'>' | /usr/bin/cut -f1 -d'<'`
if [ ! -z ${USE_MFS_VAR_SIZE} ] && [ ${USE_MFS_VAR_SIZE} -gt 0 ]; then if [ ! -z ${USE_MFS_VAR_SIZE} ] && [ ${USE_MFS_VAR_SIZE} -gt 0 ]; then
varsize="${USE_MFS_VAR_SIZE}m" varsize="${USE_MFS_VAR_SIZE}m"
else else
......
...@@ -14,7 +14,7 @@ if [ "$PLATFORM" = "pfSense" ]; then ...@@ -14,7 +14,7 @@ if [ "$PLATFORM" = "pfSense" ]; then
rm -rf /tmp/* rm -rf /tmp/*
fi fi
USE_MFS_TMPVAR=`/usr/bin/grep -c use_mfs_tmpvar /cf/conf/config.xml` USE_MFS_TMPVAR=`/usr/bin/grep -c use_mfs_tmpvar /conf/config.xml`
DISK_NAME=`/bin/df /var/db/rrd | /usr/bin/tail -1 | /usr/bin/awk '{print $1;}'` DISK_NAME=`/bin/df /var/db/rrd | /usr/bin/tail -1 | /usr/bin/awk '{print $1;}'`
DISK_TYPE=`/usr/bin/basename ${DISK_NAME} | /usr/bin/cut -c1-2` DISK_TYPE=`/usr/bin/basename ${DISK_NAME} | /usr/bin/cut -c1-2`
# If we are not on a full install, or if the full install wants RAM disks, or if the full install _was_ using RAM disks, but isn't for the next boot... # If we are not on a full install, or if the full install wants RAM disks, or if the full install _was_ using RAM disks, but isn't for the next boot...
......
...@@ -5,7 +5,7 @@ if [ `tar tzPf $1 /usr/local/etc/rc 2>/dev/null` ]; then ...@@ -5,7 +5,7 @@ if [ `tar tzPf $1 /usr/local/etc/rc 2>/dev/null` ]; then
echo " Backup file looks OK." echo " Backup file looks OK."
echo "One moment, restoring ${1}..." echo "One moment, restoring ${1}..."
if [ -f /tmp/do_not_restore_config.xml ]; then if [ -f /tmp/do_not_restore_config.xml ]; then
EXCLUDE="--exclude /cf/conf/config.xml" EXCLUDE="--exclude /conf/config.xml"
rm /tmp/do_not_restore_config.xml rm /tmp/do_not_restore_config.xml
else else
EXCLUDE="" EXCLUDE=""
......
...@@ -27,7 +27,7 @@ if [ "$PLATFORM" = "pfSense" ]; then ...@@ -27,7 +27,7 @@ if [ "$PLATFORM" = "pfSense" ]; then
find -x /tmp/* -type f -exec rm -f {} \; >/dev/null 2>&1 find -x /tmp/* -type f -exec rm -f {} \; >/dev/null 2>&1
fi fi
USE_MFS_TMPVAR=`/usr/bin/grep -c use_mfs_tmpvar /cf/conf/config.xml` USE_MFS_TMPVAR=`/usr/bin/grep -c use_mfs_tmpvar /conf/config.xml`
DISK_NAME=`/bin/df /var/db/rrd | /usr/bin/tail -1 | /usr/bin/awk '{print $1;}'` DISK_NAME=`/bin/df /var/db/rrd | /usr/bin/tail -1 | /usr/bin/awk '{print $1;}'`
DISK_TYPE=`/usr/bin/basename ${DISK_NAME} | /usr/bin/cut -c1-2` DISK_TYPE=`/usr/bin/basename ${DISK_NAME} | /usr/bin/cut -c1-2`
# If we are not on a full install, or if the full install wants RAM disks, or if the full install _was_ using RAM disks, but isn't for the next boot... # If we are not on a full install, or if the full install wants RAM disks, or if the full install _was_ using RAM disks, but isn't for the next boot...
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
NOTSYNCED="true" NOTSYNCED="true"
MAX_ATTEMPTS=3 MAX_ATTEMPTS=3
SERVER=`/bin/cat /cf/conf/config.xml | /usr/bin/grep timeservers | /usr/bin/cut -d">" -f2 | /usr/bin/cut -d"<" -f1` SERVER=`/bin/cat /conf/config.xml | /usr/bin/grep timeservers | /usr/bin/cut -d">" -f2 | /usr/bin/cut -d"<" -f1`
if [ "${SERVER}" = "" ]; then if [ "${SERVER}" = "" ]; then
exit exit
fi fi
......
...@@ -549,7 +549,7 @@ if ($_POST) { ...@@ -549,7 +549,7 @@ if ($_POST) {
} else if ($mode == "restore_ver") { } else if ($mode == "restore_ver") {
$input_errors[] = gettext("XXX - this feature may hose your config (do NOT backrev configs!) - billm"); $input_errors[] = gettext("XXX - this feature may hose your config (do NOT backrev configs!) - billm");
if ($ver2restore <> "") { if ($ver2restore <> "") {
$conf_file = '/cf/conf/backup/config-' . strtotime($ver2restore) . ".xml"; $conf_file = '/conf/backup/config-' . strtotime($ver2restore) . '.xml';
if (config_install($conf_file) == 0) { if (config_install($conf_file) == 0) {
mark_subsystem_dirty("restore"); mark_subsystem_dirty("restore");
} else { } else {
......
...@@ -46,7 +46,7 @@ if (isset($_POST['backupcount'])) { ...@@ -46,7 +46,7 @@ if (isset($_POST['backupcount'])) {
} }
conf_mount_rw(); conf_mount_rw();
$confvers = unserialize(file_get_contents('/cf/conf/backup/backup.cache')); $confvers = unserialize(file_get_contents('/conf/backup/backup.cache'));
if($_POST['newver'] != "") { if($_POST['newver'] != "") {
if(config_restore('/conf/backup/config-' . $_POST['newver'] . '.xml') == 0) if(config_restore('/conf/backup/config-' . $_POST['newver'] . '.xml') == 0)
$savemsg = sprintf(gettext('Successfully reverted to timestamp %1$s with description "%2$s".'), date(gettext("n/j/y H:i:s"), $_POST['newver']), $confvers[$_POST['newver']]['description']); $savemsg = sprintf(gettext('Successfully reverted to timestamp %1$s with description "%2$s".'), date(gettext("n/j/y H:i:s"), $_POST['newver']), $confvers[$_POST['newver']]['description']);
......
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