diff options
Diffstat (limited to 'etc')
-rw-r--r-- | etc/inc/config.inc | 4 | ||||
-rw-r--r-- | etc/inc/util.inc | 27 | ||||
-rwxr-xr-x | etc/rc.firmware | 16 | ||||
-rwxr-xr-x | etc/rc.initial.firmware_update | 20 |
4 files changed, 44 insertions, 23 deletions
diff --git a/etc/inc/config.inc b/etc/inc/config.inc index a6e871a..c8853fa 100644 --- a/etc/inc/config.inc +++ b/etc/inc/config.inc @@ -478,7 +478,7 @@ function conf_mount_ro() { return; /* firmare upgrade in progress */ - if(file_exists($g['varrun_path'] . "/firmware.lock")) + if (is_subsystem_dirty('firmwarelock')) return; /* do not umount if generating ssh keys */ @@ -1298,4 +1298,4 @@ function set_device_perms() { if($g['booting']) echo "."; $config = parse_config(); -?>
\ No newline at end of file +?> diff --git a/etc/inc/util.inc b/etc/inc/util.inc index 2f75728..21af5f5 100644 --- a/etc/inc/util.inc +++ b/etc/inc/util.inc @@ -77,6 +77,31 @@ function killbyname($procname) { mwexec("/usr/bin/killall " . escapeshellarg($procname)); } +function is_subsystem_dirty($subsystem = "") { + global $g; + + if ($subsystem == "") + return false; + + if (file_exists("{$g['varrun_path']}/{$subsystem}.dirty")) + return true; + + return false; +} + +function mark_subsystem_dirty($subsystem = "") { + global $g; + + if (!file_put_contents("{$g['varrun_path']}/{$subsystem}.dirty", "DIRTY")) + log_error("WARNING: Could not mark subsystem: {$subsytem} dirty"); +} + +function clear_subsystem_dirty($subsystem = "") { + global $g; + + @unlink("{$g['varrun_path']}/{$subsystem}.dirty"); +} + function config_lock() { log_error("config_lock() is depricated please use lock()."); return; @@ -992,4 +1017,4 @@ function isAjax() { } -?>
\ No newline at end of file +?> diff --git a/etc/rc.firmware b/etc/rc.firmware index 7d31383..f9e817d 100755 --- a/etc/rc.firmware +++ b/etc/rc.firmware @@ -117,7 +117,7 @@ enable) echo "" > /cf/upgrade_log.txt ;; auto) - touch /var/run/firmware.lock + touch /var/run/firmwarelock.dirty backup_chflags remove_chflags /etc/rc.firmware_auto @@ -140,7 +140,7 @@ pfSenseNanoBSDupgrade) exit 1 fi - touch /var/run/firmware.lock + touch /var/run/firmwarelock.dirty echo "NanoBSD Firmware upgrade in progress..." >> /cf/upgrade_log.txt 2>&1 echo "NanoBSD Firmware upgrade in progress..." | wall @@ -216,7 +216,7 @@ pfSenseNanoBSDupgrade) /sbin/fsck_ffs -y /dev/$COMPLETE_PATH >> /cf/upgrade_log.txt 2>&1 if [ $? != 0 ]; then file_notice "UpgradeFailure" "{\$g['product_name']} upgrade has failed. Your system has been left in a usable state." - rm /var/run/firmware.lock + rm /var/run/firmwarelock.dirty /etc/rc.conf_mount_ro exit 1 fi @@ -248,7 +248,7 @@ pfSenseNanoBSDupgrade) if [ $? != 0 ]; then echo "Something went wrong when trying to update the fstab entry. Aborting upgrade." file_notice "UpgradeFailure" "Something went wrong when trying to update the fstab entry. Aborting upgrade." - rm /var/run/firmware.lock + rm /var/run/firmwarelock.dirty umount /tmp/$GLABEL_SLICE /etc/rc.conf_mount_ro exit 1 @@ -290,7 +290,7 @@ pfSenseNanoBSDupgrade) echo "/sbin/sysctl kern.geom.debugflags=0" >> /cf/upgrade_log.txt /sbin/sysctl kern.geom.debugflags=0 >> /cf/upgrade_log.txt 2>&1 - rm -f /var/run/firmware.lock + rm -f /var/run/firmwarelock.dirty sh /etc/rc.reboot ;; @@ -311,7 +311,7 @@ pfSenseupgrade) echo "NanoBSD upgrade starting" >> /cf/upgrade_log.txt echo "" >> /cf/upgrade_log.txt - touch /var/run/firmware.lock + touch /var/run/firmwarelock.dirty touch /cf/upgrade_log.txt echo "" >> /cf/upgrade_log.txt @@ -388,7 +388,7 @@ pfSenseupgrade) /etc/rc.conf_mount_ro # release the firmware lock - rm -f /var/run/firmware.lock + rm -f /var/run/firmwarelock.dirty /bin/sync # If the archive has unpacked a file called @@ -403,7 +403,7 @@ pfSenseupgrade) ;; delta_update) - touch /var/run/firmware.lock + touch /var/run/firmwarelock.dirty backup_chflags remove_chflags binary_update $IMG diff --git a/etc/rc.initial.firmware_update b/etc/rc.initial.firmware_update index ec8aad5..cdbaa9b 100755 --- a/etc/rc.initial.firmware_update +++ b/etc/rc.initial.firmware_update @@ -2,18 +2,15 @@ <?php -$g['booting'] = true; require("globals.inc"); +$g['booting'] = true; echo "Starting the {$g['product_name']} console firmware update system"; require("functions.inc"); echo "."; -require("config.inc"); -echo "."; -$g['booting'] = false; -$d_fwupenabled_path = $g['varrun_path'] . "/fwup.enabled"; +$g['booting'] = false; $fp = fopen('php://stdin', 'r'); @@ -46,7 +43,7 @@ switch ($command) { $status = does_url_exist($url); if($status) { conf_mount_rw(); - touch($d_fwupenabled_path); + mark_subsystem_dirty('firmware'); if(file_exists("/root/firmware.tgz")) unlink("/root/firmware.tgz"); echo "\nFetching file size...\n"; @@ -116,7 +113,7 @@ switch ($command) { if(stristr($fp,"bdiff")) $type = "nanobsd"; if(file_exists($path)) { - touch($d_fwupenabled_path); + mark_subsystem_dirty('firmware'); do_upgrade($path, $type); } else { echo "\nCould not find file.\n\n"; @@ -163,7 +160,7 @@ function check_for_kernel_file() { function do_upgrade($path, $type) { global $g; - touch($g['varrun_path'] . "/firmware.lock"); + mark_subsystem_dirty('firmwarelock'); check_for_kernel_file(); echo "\nOne moment please...\nInvoking firmware upgrade..."; if($type == "bdiff") @@ -173,17 +170,16 @@ function do_upgrade($path, $type) { else mwexec_bg("/etc/rc.firmware pfSenseupgrade $path"); sleep(10); - while(file_exists("{$g['varrun_path']}/firmware.lock")) { + while(is_subsystem_dirty('firmwarelock')) { sleep(1); echo "."; } sleep(10); echo "Done. Rebooting...\n\n"; - if(file_exists($g['varrun_path'] . "/firmware.lock")) - unlink($g['varrun_path'] . "/firmware.lock"); + clear_subsystem_dirty('firmwarelock'); } exec("rm -f /root/*.md5"); fclose($fp); -?>
\ No newline at end of file +?> |