diff options
-rwxr-xr-x | etc/rc.initial | 6 | ||||
-rwxr-xr-x | etc/rc.initial.firmware_update | 64 |
2 files changed, 69 insertions, 1 deletions
diff --git a/etc/rc.initial b/etc/rc.initial index 66bab08..51258c8 100755 --- a/etc/rc.initial +++ b/etc/rc.initial @@ -77,6 +77,7 @@ echo " 9) PFtop" echo "10) Filter Logs" echo "11) Restart webConfigurator" echo "12) pfSense PHP shell" +echo "13) Upgrade from console" for i in /var/db/pfi/capable_*; do if [ -f $i -a ! -L /cf/conf ]; then echo "98) Move configuration file to removable device" @@ -134,7 +135,10 @@ case ${opmode} in 12) /usr/local/sbin/pfSsh.php ;; -13) +13) + /etc/rc.initial_firmware_update + ;; +14) /etc/rc.banner ;; 98) diff --git a/etc/rc.initial.firmware_update b/etc/rc.initial.firmware_update new file mode 100755 index 0000000..74ee6e4 --- /dev/null +++ b/etc/rc.initial.firmware_update @@ -0,0 +1,64 @@ +#!/usr/local/bin/php -f + +<?php + +echo "Starting the pfSense console firmware update system"; + +echo "."; +require("globals.inc"); +$g['booting'] = true; +require("functions.inc"); +echo "."; +require("config.inc"); +echo "."; +$g['booting'] = false; + +$fp = fopen('php://stdin', 'r'); + +echo ".\n\n"; + +$shell_active = true; + +echo "1) Update from a URL\n"; +echo "2) Update from a local file\n"; +echo "Q) Quit\n"; + +echo "\nPlease select an option to continue: "; + +$command = strtoupper(chop(fgets($fp))); + +switch ($command) { + case "q": + case "quit": + echo "\n"; + die; + break; + case "1": + echo "\nEnter the URL to the .tgz update file:\n> "; + $url = chop(fgets($fp)); + $status = does_url_exist($url); + if($status) { + exec("fetch -v -o /tmp/firmware.tgz \"$url\""); + if(file_exists("/tmp/firmware.tgz")) + do_upgrade("/tmp/firmware.tgz"); + } else { + echo "\nCould not download update.\n\n"; + die -1; + } + case "2": + echo "\nEnter the complete path to the .tgz update file: "; + $path = chop(fgets($fp)); + if(file_exists($path)) { + do_upgrade($path); + } else { + echo "\nCould not find file.\n\n"; + die -1; + } +} + +function do_upgrade($path) { + echo "\nOne moment please... Invoking firmware upgrade...\n"; + exec("/etc/rc.firmware pfSenseupgrade $path"); +} + +?>
\ No newline at end of file |