Commit 915f04b3 authored by Franco Fichtner's avatar Franco Fichtner

firmware: embed the base system upgrade into the GUI flow

parent 3505b042
......@@ -29,6 +29,7 @@ package=$1
pkg_running=`ps -x | grep "pkg " | grep -v "grep" | grep -v "pkg_upgrade.sh"`
PKG_PROGRESS_FILE=/tmp/pkg_upgrade.progress
REBOOT=
# Truncate upgrade progress file
: > ${PKG_PROGRESS_FILE}
......@@ -40,10 +41,15 @@ if [ -z "$pkg_running" ]; then
if [ "$package" == "all" ]; then
# update all installed packages
pkg upgrade -y >> ${PKG_PROGRESS_FILE}
# restart the web server
/usr/local/opnsense/service/configd_ctl.py 'webgui restart' >> ${PKG_PROGRESS_FILE}
# remove no longer referenced packages
pkg autoremove -y >> ${PKG_PROGRESS_FILE}
# restart the web server
/usr/local/etc/rc.restart_webgui >> ${PKG_PROGRESS_FILE}
# if we can update base, we'll do that as well
if opnsense-update -c; then
if opnsense-update >> ${PROGRESS_FILE}; then
REBOOT=1
fi
fi
elif [ "$package" == "pkg" ]; then
pkg upgrade -y $package >> ${PKG_PROGRESS_FILE}
else
......@@ -55,4 +61,8 @@ else
echo 'Upgrade already in progress' >> ${PKG_PROGRESS_FILE}
fi
echo '***DONE***' >> ${PKG_PROGRESS_FILE}
if [ -n "${REBOOT}" ]; then
echo '***REBOOT***' >> ${PKG_PROGRESS_FILE}
else
echo '***DONE***' >> ${PKG_PROGRESS_FILE}
fi
......@@ -247,7 +247,6 @@ include("head.inc");
}
function updatestatus() {
jQuery.ajax({
type: "POST",
url: '/system_firmware_check.php',
......@@ -255,10 +254,12 @@ include("head.inc");
success:function(data, textStatus, jqXHR) {
jQuery('#output').prop('innerHTML',data);
document.getElementById("output").scrollTop = document.getElementById("output").scrollHeight ;
if ( data.indexOf('***DONE***') < 0 ) {
setTimeout(function() { updatestatus(); }, 500);
if (data.indexOf('***REBOOT***') >= 0) {
jQuery('#updatestatus').html('<span class="text-info">Upgrade done! A reboot is erquired.</span><br/>');
if (data.indexOf('***DONE***') >= 0) {
jQuery('#updatestatus').html('<a href="/system_firmware_check.php"><span class="btn btn-primary btn-xs">Check to refresh</span></a>&nbsp;<span class="text-info">Upgrade done!</span><br/>');
} else {
jQuery('#updatestatus').html('<a href="/system_firmware_check.php"><span class="btn btn-primary btn-xs">Check to refresh</span></a>&nbsp;<span class="text-info">Upgrade Done!</span><br/>');
setTimeout(function() { updatestatus(); }, 500);
}
}
});
......
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