Commit da4675cb authored by Jos Schellevis's avatar Jos Schellevis

Upgrade for firmware upgrade add check for pkg package and change scripting to...

Upgrade for firmware upgrade add check for pkg package and change scripting to allow sinlge package upgrade, also fixes #27
parent 1b6984c7
...@@ -24,18 +24,29 @@ ...@@ -24,18 +24,29 @@
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE. # POSSIBILITY OF SUCH DAMAGE.
package=$1
pkg_running=`ps -x | grep "pkg " | grep -v "grep"` pkg_running=`ps -x | grep "pkg " | grep -v "grep"`
if [ "$pkg_running" == "" ]; then if [ "$pkg_running" == "" ]; then
if [ -f /tmp/pkg_upgrade.progress ]; then if [ -f /tmp/pkg_upgrade.progress ]; then
# Remove leftovers from previous upgrade first # Remove leftovers from previous upgrade first
rm /tmp/pkg_upgrade.progress rm /tmp/pkg_upgrade.progress
fi fi
# start pkg upgrade if [ "$package" == "all" ]; then
echo '***STARTING UPGRADE***' > /tmp/pkg_upgrade.progress # start pkg upgrade
pkg upgrade -y >> /tmp/pkg_upgrade.progress echo '***STARTING UPGRADE***' > /tmp/pkg_upgrade.progress
echo '***DONE***' >> /tmp/pkg_upgrade.progress pkg upgrade -y >> /tmp/pkg_upgrade.progress
echo '***CHECKING FOR MORE UPGRADES, CAN TAKE 30 SECONDS***' >> /tmp/pkg_upgrade.progress
/usr/local/opnsense/scripts/pkg_updatecheck.sh
echo '***DONE***' >> /tmp/pkg_upgrade.progress
else
# start pkg upgrade
echo '***STARTING UPGRADE - ONE PACKAGE***' > /tmp/pkg_upgrade.progress
pkg upgrade -y $package >> /tmp/pkg_upgrade.progress
echo '***CHECKING FOR MORE UPGRADES, CAN TAKE 30 SECONDS***' >> /tmp/pkg_upgrade.progress
/usr/local/opnsense/scripts/pkg_updatecheck.sh
echo '***DONE***' >> /tmp/pkg_upgrade.progress
fi
else else
echo 'Upgrade already in progress' echo 'Upgrade already in progress'
echo '***DONE***' echo '***DONE***'
/usr/local/opnsense/scripts/pkg_updatecheck.sh
fi fi
...@@ -36,6 +36,7 @@ require_once("script/load_phalcon.php"); ...@@ -36,6 +36,7 @@ require_once("script/load_phalcon.php");
$file_pkg_status="/tmp/pkg_status.json"; $file_pkg_status="/tmp/pkg_status.json";
$file_upgrade_progress="/tmp/pkg_upgrade.progress"; $file_upgrade_progress="/tmp/pkg_upgrade.progress";
$pkgonly=false;
$pkg_status = array(); $pkg_status = array();
...@@ -52,7 +53,11 @@ if($_POST['action'] == 'pkg_upgrade') { ...@@ -52,7 +53,11 @@ if($_POST['action'] == 'pkg_upgrade') {
$shell_output = array(); $shell_output = array();
$shell = new OPNsense\Core\Shell(); $shell = new OPNsense\Core\Shell();
// execute shell command and collect (only valid) info into named array // execute shell command and collect (only valid) info into named array
$shell->exec("/usr/local/opnsense/scripts/pkg_upgrade.sh > /dev/null 2 > /dev/null < /dev/null &",false,false,$shell_output); if ( $pkgonly == true ) {
$shell->exec("/usr/local/opnsense/scripts/pkg_upgrade.sh pkg > /dev/null 2 > /dev/null < /dev/null &",false,false,$shell_output);
} else {
$shell->exec("/usr/local/opnsense/scripts/pkg_upgrade.sh all > /dev/null 2 > /dev/null < /dev/null &",false,false,$shell_output);
}
} }
if($_POST['action'] == 'update_status' ) { if($_POST['action'] == 'update_status' ) {
...@@ -78,6 +83,13 @@ if($_REQUEST['getupdatestatus']) { ...@@ -78,6 +83,13 @@ if($_REQUEST['getupdatestatus']) {
echo "<span class='text-danger'>".gettext("Repository Problem")."</span><br/><span class='btn btn-primary' onclick='checkupdate()'>".gettext("Click to retry now")."</span>"; echo "<span class='text-danger'>".gettext("Repository Problem")."</span><br/><span class='btn btn-primary' onclick='checkupdate()'>".gettext("Click to retry now")."</span>";
} elseif ($pkg_status["updates"]=="0") { } elseif ($pkg_status["updates"]=="0") {
echo "<span class='text-info'>".gettext("At")." <small>".$pkg_status["last_check"]."</small>".gettext(" no updates found.")."<br/><span class='btn btn-primary' onclick='checkupdate()'>".gettext("Click to check now")."</span>"; echo "<span class='text-info'>".gettext("At")." <small>".$pkg_status["last_check"]."</small>".gettext(" no updates found.")."<br/><span class='btn btn-primary' onclick='checkupdate()'>".gettext("Click to check now")."</span>";
} elseif ( $pkg_status["updates"] == 1 && $pkg_status["upgrade_packages"][0]["name"] == "pkg" ) {
echo "<span class='text-danger'>".gettext("There is a mandatory update for the package manager.").
"</span><span class='text-info'><small>(When last checked at: ".$pkg_status["last_check"]." )</small></span><br />".
"<span class='text-danger'>".gettext("Upgrade pkg and recheck, there maybe other updates available.").
"</span><br/><span class='btn btn-primary' onclick='upgradenow()'>".gettext("Upgrade Now").
"</span>&nbsp;<span class='btn btn-primary' onclick='checkupdate()'>".gettext("Re-Check Now")."</span>";
$pkgonly=true;
} else { } else {
echo "<span class='text-danger'>".gettext("A total of ").$pkg_status["updates"].gettext(" update(s) are available.")."<span class='text-info'><small>(When last checked at: ".$pkg_status["last_check"]." )</small></span>"."</span><br/><span class='btn btn-primary' onclick='upgradenow()'>".gettext("Upgrade Now")."</span>&nbsp;<span class='btn btn-primary' onclick='checkupdate()'>".gettext("Re-Check Now")."</span>"; echo "<span class='text-danger'>".gettext("A total of ").$pkg_status["updates"].gettext(" update(s) are available.")."<span class='text-info'><small>(When last checked at: ".$pkg_status["last_check"]." )</small></span>"."</span><br/><span class='btn btn-primary' onclick='upgradenow()'>".gettext("Upgrade Now")."</span>&nbsp;<span class='btn btn-primary' onclick='checkupdate()'>".gettext("Re-Check Now")."</span>";
} }
......
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