From 4d54029ec2cf5412c82f2e142fcfb0396b05971d Mon Sep 17 00:00:00 2001 From: Franco Fichtner Date: Sat, 16 Dec 2017 19:57:42 +0000 Subject: [PATCH] firmware: allow to reinstall kernel and base with reboot #1992 --- src/opnsense/scripts/firmware/reinstall.sh | 36 ++++++++++++++++++++-- 1 file changed, 34 insertions(+), 2 deletions(-) diff --git a/src/opnsense/scripts/firmware/reinstall.sh b/src/opnsense/scripts/firmware/reinstall.sh index dc2e70060..3c22ec792 100755 --- a/src/opnsense/scripts/firmware/reinstall.sh +++ b/src/opnsense/scripts/firmware/reinstall.sh @@ -27,11 +27,43 @@ PKG_PROGRESS_FILE=/tmp/pkg_upgrade.progress PACKAGE=$1 +REBOOT= # Truncate upgrade progress file : > ${PKG_PROGRESS_FILE} echo "***GOT REQUEST TO REINSTALL: $PACKAGE***" >> ${PKG_PROGRESS_FILE} -pkg install -yf $PACKAGE >> ${PKG_PROGRESS_FILE} 2>&1 -pkg autoremove -y >> ${PKG_PROGRESS_FILE} 2>&1 + +if [ "${PACKAGE}" = "base" ]; then + # XXX need a portable command + if [ ! -f /usr/local/opnsense/version/base.lock ]; then + if opnsense-update -bf >> ${PKG_PROGRESS_FILE} 2>&1; then + REBOOT=1 + fi + else + # for locked message only + opnsense-update -b >> ${PKG_PROGRESS_FILE} 2>&1 + fi +elif [ "${PACKAGE}" = "kernel" ]; then + # XXX need a portable command + if [ ! -f /usr/local/opnsense/version/kernel.lock ]; then + if opnsense-update -kf >> ${PKG_PROGRESS_FILE} 2>&1; then + REBOOT=1 + fi + else + # for locked message only + opnsense-update -k >> ${PKG_PROGRESS_FILE} 2>&1 + fi +else + pkg install -yf $PACKAGE >> ${PKG_PROGRESS_FILE} 2>&1 + pkg autoremove -y >> ${PKG_PROGRESS_FILE} 2>&1 +fi + +if [ -n "${REBOOT}" ]; then + echo '***REBOOT***' >> ${PKG_PROGRESS_FILE} + # give the frontend some time to figure out that a reboot is coming + sleep 5 + /usr/local/etc/rc.reboot +fi + echo '***DONE***' >> ${PKG_PROGRESS_FILE}