From b58554994bd66a2c9dc20657f72a0fac2c8dbaee Mon Sep 17 00:00:00 2001 From: Scott Ullrich Date: Sat, 27 Jun 2009 18:41:54 -0400 Subject: [PATCH] Add support for the NanoBSD platform --- etc/rc.initial_firmware_update | 48 +++++++++++++++++++++++----------- 1 file changed, 33 insertions(+), 15 deletions(-) diff --git a/etc/rc.initial_firmware_update b/etc/rc.initial_firmware_update index bb1beb410c..3853c2ba49 100644 --- a/etc/rc.initial_firmware_update +++ b/etc/rc.initial_firmware_update @@ -2,12 +2,11 @@ $file_md5) { echo "\n\nMD5 checksum does not match. Cancelling upgrade.\n\n"; - fclose($fp); exec("rm -f /root/*.md5"); + fclose($fp); die -1; } echo "\nMD5 checksum matches.\n"; exec("rm -f /root/*.md5"); } - if(file_exists("/root/firmware.tgz")) - do_upgrade("/root/firmware.tgz"); + if(stristr($url,"bdiff")) + $type = "bdiff"; + if(stristr($url,"bdiff")) + $type = "nanobsd"; + if(file_exists("/root/firmware.tgz")) { + do_upgrade("/root/firmware.tgz", $type); + exit; + } } else { echo "\nCould not download update.\n\n"; fclose($fp); @@ -103,9 +108,13 @@ switch ($command) { fclose($fp); die; } + if(stristr($fp,"bdiff")) + $type = "bdiff"; + if(stristr($fp,"bdiff")) + $type = "nanobsd"; if(file_exists($path)) { touch($d_fwupenabled_path); - do_upgrade($path); + do_upgrade($path, $type); } else { echo "\nCould not find file.\n\n"; fclose($fp); @@ -149,18 +158,27 @@ function check_for_kernel_file() { } } -function do_upgrade($path) { - global $fp, $g; - touch($g['varrun_path'] . "/firmware.lock"); +function do_upgrade($path, $type) { + global $g; + touch($g['varrun_path'] . "/firmware.lock"); check_for_kernel_file(); - echo "\nOne moment please... Invoking firmware upgrade...\n"; - exec("/etc/rc.firmware pfSenseupgrade $path"); - unlink_if_exists($path); - unlink_if_exists($g['varrun_path'] . "/firmware.lock"); - die; + echo "\nOne moment please...\nInvoking firmware upgrade..."; + if($type == "bdiff") + mwexec_bg("/etc/rc.firmware delta_update $path"); + elseif($type == "nanobsd") + mwexec_bg("/etc/rc.firmware pfSenseNanoBSDupgrade $path"); + else + mwexec_bg("/etc/rc.firmware pfSenseupgrade $path"); + sleep(10); + while(file_exists("{$g['varrun_path']}/firmware.lock")) { + sleep(1); + echo "."; + } + echo "Done. Rebooting...\n\n"; + unlink($g['varrun_path'] . "/firmware.lock"); } exec("rm -f /root/*.md5"); fclose($fp); -?> +?> \ No newline at end of file