diff --git a/etc/inc/rrd.inc b/etc/inc/rrd.inc index 6f443968b4..2566b8d179 100644 --- a/etc/inc/rrd.inc +++ b/etc/inc/rrd.inc @@ -78,6 +78,10 @@ function restore_rrd() { } unlink($xml_file); } + /* 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'])) { + unlink_if_exists("{$g['cf_conf_path']}/rrd.tgz"); + } return true; } return false; @@ -270,9 +274,7 @@ function enable_rrd_graphing() { chown($rrddbpath, "nobody"); if ($g['booting']) { - if ($g['platform'] != "pfSense") { - restore_rrd(); - } + restore_rrd(); } /* db update script */ diff --git a/etc/inc/services.inc b/etc/inc/services.inc index 03325cddbd..81d2ee6994 100644 --- a/etc/inc/services.inc +++ b/etc/inc/services.inc @@ -358,18 +358,20 @@ function services_dhcpdv4_configure() { $is_olsr_enabled = true; if ($g['booting']) { - if ($g['platform'] != "pfSense") { - /* restore the leases, if we have them */ - if (file_exists("{$g['cf_conf_path']}/dhcpleases.tgz")) { - $dhcprestore = ""; - $dhcpreturn = ""; - exec("cd /;LANG=C /usr/bin/tar -xzf {$g['cf_conf_path']}/dhcpleases.tgz 2>&1", $dhcprestore, $dhcpreturn); - $dhcprestore = implode(" ", $dhcprestore); - 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")); - } + /* restore the leases, if we have them */ + if (file_exists("{$g['cf_conf_path']}/dhcpleases.tgz")) { + $dhcprestore = ""; + $dhcpreturn = ""; + exec("cd /;LANG=C /usr/bin/tar -xzf {$g['cf_conf_path']}/dhcpleases.tgz 2>&1", $dhcprestore, $dhcpreturn); + $dhcprestore = implode(" ", $dhcprestore); + 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")); } } + /* 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'])) { + unlink_if_exists("{$g['cf_conf_path']}/dhcpleases.tgz"); + } } $syscfg = $config['system']; diff --git a/etc/rc b/etc/rc index 73674eaca2..9b049f162e 100755 --- a/etc/rc +++ b/etc/rc @@ -73,27 +73,22 @@ if [ "$PLATFORM" = "pfSense" ]; then fi fi -if [ "$PLATFORM" = "cdrom" ]; then +if [ "${PLATFORM}" = "cdrom" ]; then /etc/rc.cdrom -fi - -if [ "$PLATFORM" = "embedded" ]; then - export PKG_TMPDIR=/root/ - /etc/rc.embedded -fi - -if [ "$PLATFORM" = "nanobsd" ]; then - export PKG_TMPDIR=/root/ - /etc/rc.embedded -fi - -# Mount /. If it fails run a fsck. -if [ ! "$PLATFORM" = "cdrom" ] ; then +else + # Mount /. If it fails run a fsck. if [ "$PLATFORM" = "nanobsd" ]; then + export PKG_TMPDIR=/root/ /sbin/mount -uw / || (/sbin/fsck -fy; /sbin/mount -uw /) else /sbin/mount -a || (/sbin/fsck -fy; /sbin/mount -a) fi + + USE_MFS_TMPVAR=`/usr/bin/grep -c use_mfs_tmpvar /cf/conf/config.xml` + if [ "${PLATFORM}" = "nanobsd" ] || [ "${PLATFORM}" = "embedded" ] || [ ${USE_MFS_TMPVAR} -gt 0 ]; then + /etc/rc.embedded + fi + # If /conf is a directory, convert it to a symlink to /cf/conf if [ -d "/conf" ]; then # If item is not a symlink then rm and recreate @@ -165,7 +160,7 @@ if [ "$PLATFORM" = "cdrom" ] ; then # do nothing for cdrom platform elif [ "$PLATFORM" = "embedded" ] ; then # do nothing for embedded platform -elif [ "$PLATFORM" = "nanobsd" ] ; then +elif [ "$PLATFORM" = "nanobsd" ] || [ ${USE_MFS_TMPVAR} -gt 0 ]; then # Ensure that old-style PKG packages can be persistent across reboots /bin/mkdir -p /root/var/db/pkg /bin/rm -rf /var/db/pkg @@ -180,6 +175,14 @@ else SWAPDEVICE=`/bin/cat /etc/fstab | /usr/bin/grep swap | /usr/bin/cut -f1` /sbin/swapon -a 2>/dev/null >/dev/null /etc/rc.savecore + + if [ -d /root/var/db/pkg ]; then + # User must have just disabled RAM disks, move these back into place. + /bin/mkdir -p /var/db/pkg + /bin/mv /root/var/db/pkg /var/db/pkg + /bin/mkdir -p /var/db/pbi + /bin/mv /root/var/db/pkg /var/db/pbi + fi fi if [ "$PLATFORM" = "cdrom" ] ; then diff --git a/etc/rc.embedded b/etc/rc.embedded index ada4558696..426495fa73 100755 --- a/etc/rc.embedded +++ b/etc/rc.embedded @@ -4,27 +4,27 @@ # For pfSense # Size of /tmp -tmpsize="40m" +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'<'` +if [ ${USE_MFS_TMP_SIZE} -gt 0 ]; then + tmpsize="${USE_MFS_TMP_SIZE}m" +else + tmpsize="40m" +fi # Size of /var -varsize="60m" +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'<'` +if [ ${USE_MFS_VAR_SIZE} -gt 0 ]; then + varsize="${USE_MFS_VAR_SIZE}m" +else + varsize="60m" +fi # Run some initialization routines [ -f /etc/rc.d/uzip ] && /etc/rc.d/uzip start -echo -n "Setting up embedded specific environment..." -# Initialize MFS for /tmp. Partly taken from /etc/rc.d/var -if (/bin/mkdir -p /tmp/.diskless 2> /dev/null); then - rmdir /tmp/.diskless -else - mdmfs -S -M -s ${tmpsize} md /tmp -fi -# Initialize MFS for /var. Partly taken from /etc/rc.d/var -if (/bin/mkdir -p /var/.diskless 2> /dev/null); then - rmdir /var/.diskless -else - mdmfs -S -M -s ${varsize} md /var -fi +echo -n "Setting up memory disks..." +mdmfs -S -M -s ${tmpsize} md /tmp +mdmfs -S -M -s ${varsize} md /var # Create some needed directories /bin/mkdir -p /var/db diff --git a/etc/rc.reboot b/etc/rc.reboot index 4bb28a196f..afdc93cf00 100755 --- a/etc/rc.reboot +++ b/etc/rc.reboot @@ -14,7 +14,13 @@ sleep 1 PLATFORM=`cat /etc/platform` if [ "$PLATFORM" = "pfSense" ]; then rm -rf /tmp/* -else +fi + +USE_MFS_TMPVAR=`/usr/bin/grep -c use_mfs_tmpvar /cf/conf/config.xml` +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` +# 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 [ "${PLATFORM}" != "pfSense" ] || [ ${USE_MFS_TMPVAR} -gt 0 ] || [ "${DISK_TYPE}" = "md" ]; then /etc/rc.backup_rrd.sh /etc/rc.backup_dhcpleases.sh fi diff --git a/etc/rc.shutdown b/etc/rc.shutdown index c7e8b25bcd..c63e5e5288 100755 --- a/etc/rc.shutdown +++ b/etc/rc.shutdown @@ -25,7 +25,13 @@ export PATH PLATFORM=`cat /etc/platform` if [ "$PLATFORM" = "pfSense" ]; then find -x /tmp/* -type f -exec rm -f {} \; -else +fi + +USE_MFS_TMPVAR=`/usr/bin/grep -c use_mfs_tmpvar /cf/conf/config.xml` +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` +# 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 [ "${PLATFORM}" != "pfSense" ] || [ ${USE_MFS_TMPVAR} -gt 0 ] || [ "${DISK_TYPE}" = "md" ]; then /etc/rc.backup_rrd.sh /etc/rc.backup_dhcpleases.sh fi diff --git a/usr/local/www/diag_nanobsd.php b/usr/local/www/diag_nanobsd.php index 80bb87eb7a..df3a7e4990 100755 --- a/usr/local/www/diag_nanobsd.php +++ b/usr/local/www/diag_nanobsd.php @@ -99,15 +99,6 @@ EOF; nanobsd_detect_slice_info(); } -if (isset($_POST['rrdbackup'])) { - $config['system']['rrdbackup'] = $_POST['rrdbackup']; - install_cron_job("/etc/rc.backup_rrd.sh", ($config['system']['rrdbackup'] > 0), $minute="0", "*/{$config['system']['rrdbackup']}"); -} -if (isset($_POST['dhcpbackup'])) { - $config['system']['dhcpbackup'] = $_POST['dhcpbackup']; - install_cron_job("/etc/rc.backup_dhcpleases.sh", ($config['system']['dhcpbackup'] > 0), $minute="0", "*/{$config['system']['dhcpbackup']}"); -} - if ($_POST['changero']) { if (is_writable("/")) { conf_mount_ro(); @@ -240,42 +231,11 @@ if ($savemsg)