mirror of
https://github.com/lucaspalomodevelop/core.git
synced 2026-03-14 16:44:39 +00:00
firmware: single spot for update/upgrade code #4718
This commit is contained in:
parent
dc883ebbba
commit
eb6cbc0164
@ -27,13 +27,10 @@
|
||||
|
||||
set -e
|
||||
|
||||
LOCKFILE="/tmp/pkg_upgrade.progress"
|
||||
PIPEFILE="/tmp/pkg_upgrade.pipe"
|
||||
RELEASE=$(opnsense-update -vR)
|
||||
TEE="/usr/bin/tee -a"
|
||||
|
||||
if [ "${1}" = "upgrade" ]; then
|
||||
: # ok, unconditional major upgrade
|
||||
if [ "${1}" = "upgrade" -a -n "${2}" ]; then
|
||||
RELEASE=${2}
|
||||
elif [ "${1}" = "ALLOW_RISKY_MAJOR_UPGRADE" -a -n "${RELEASE}" ]; then
|
||||
: # ok, conditional major upgrade
|
||||
else
|
||||
@ -41,47 +38,10 @@ else
|
||||
RELEASE=
|
||||
fi
|
||||
|
||||
: > ${LOCKFILE}
|
||||
rm -f ${PIPEFILE}
|
||||
mkfifo ${PIPEFILE}
|
||||
|
||||
if [ -z "${RELEASE}" ]; then
|
||||
# XXX essentially this is a copy of update.sh
|
||||
echo "***GOT REQUEST TO UPDATE***" >> ${LOCKFILE}
|
||||
|
||||
# figure out the release type from config
|
||||
SUFFIX="-$(pluginctl -g system.firmware.type)"
|
||||
if [ "${SUFFIX}" = "-" ]; then
|
||||
SUFFIX=
|
||||
fi
|
||||
|
||||
# upgrade all packages if possible
|
||||
(opnsense-update -pt "opnsense${SUFFIX}" 2>&1) | ${TEE} ${LOCKFILE}
|
||||
|
||||
# trigger a webgui restart to cope with changes
|
||||
(/usr/local/etc/rc.restart_webgui 2>&1) | ${TEE} ${LOCKFILE}
|
||||
|
||||
# if we can update base, we'll do that as well
|
||||
${TEE} ${LOCKFILE} < ${PIPEFILE} &
|
||||
if opnsense-update -c > ${PIPEFILE} 2>&1; then
|
||||
${TEE} ${LOCKFILE} < ${PIPEFILE} &
|
||||
if opnsense-update -bk > ${PIPEFILE} 2>&1; then
|
||||
echo '***REBOOT***' >> ${LOCKFILE}
|
||||
sleep 5
|
||||
/usr/local/etc/rc.reboot
|
||||
fi
|
||||
fi
|
||||
# already locked here, ok to call without launcher.sh
|
||||
/usr/local/opnsense/scripts/firmware/update.sh
|
||||
else
|
||||
# XXX essentially this is a copy of upgrade.sh
|
||||
echo "***GOT REQUEST TO UPGRADE***" >> ${LOCKFILE}
|
||||
|
||||
# upgrade to a major release
|
||||
${TEE} ${LOCKFILE} < ${PIPEFILE} &
|
||||
if opnsense-update -u > ${PIPEFILE} 2>&1; then
|
||||
echo '***REBOOT***' >> ${LOCKFILE}
|
||||
sleep 5
|
||||
/usr/local/etc/rc.reboot
|
||||
fi
|
||||
# already locked here, ok to call without launcher.sh
|
||||
/usr/local/opnsense/scripts/firmware/upgrade.sh
|
||||
fi
|
||||
|
||||
echo '***DONE***' >> ${LOCKFILE}
|
||||
|
||||
@ -25,12 +25,13 @@
|
||||
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
# POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
PKG_PROGRESS_FILE=/tmp/pkg_upgrade.progress
|
||||
LOCKFILE="/tmp/pkg_upgrade.progress"
|
||||
PIPEFILE="/tmp/pkg_upgrade.pipe"
|
||||
TEE="/usr/bin/tee -a"
|
||||
|
||||
# Truncate upgrade progress file
|
||||
: > ${PKG_PROGRESS_FILE}
|
||||
: > ${LOCKFILE}
|
||||
|
||||
echo "***GOT REQUEST TO UPDATE***" >> ${PKG_PROGRESS_FILE}
|
||||
echo "***GOT REQUEST TO UPDATE***" >> ${LOCKFILE}
|
||||
|
||||
# figure out the release type from config
|
||||
SUFFIX="-$(pluginctl -g system.firmware.type)"
|
||||
@ -39,19 +40,20 @@ if [ "${SUFFIX}" = "-" ]; then
|
||||
fi
|
||||
|
||||
# upgrade all packages if possible
|
||||
opnsense-update -pt "opnsense${SUFFIX}" >> ${PKG_PROGRESS_FILE} 2>&1
|
||||
(opnsense-update -pt "opnsense${SUFFIX}" 2>&1) | ${TEE} ${LOCKFILE}
|
||||
|
||||
# restart the web server
|
||||
/usr/local/etc/rc.restart_webgui >> ${PKG_PROGRESS_FILE} 2>&1
|
||||
(/usr/local/etc/rc.restart_webgui 2>&1) | ${TEE} ${LOCKFILE}
|
||||
|
||||
# if we can update base, we'll do that as well
|
||||
if opnsense-update -c >> ${PKG_PROGRESS_FILE} 2>&1; then
|
||||
if opnsense-update -bk >> ${PKG_PROGRESS_FILE} 2>&1; then
|
||||
echo '***REBOOT***' >> ${PKG_PROGRESS_FILE}
|
||||
# give the frontend some time to figure out that a reboot is coming
|
||||
${TEE} ${LOCKFILE} < ${PIPEFILE} &
|
||||
if opnsense-update -c > ${PIPEFILE} 2>&1; then
|
||||
${TEE} ${LOCKFILE} < ${PIPEFILE} &
|
||||
if opnsense-update -bk > ${PIPEFILE} 2>&1; then
|
||||
echo '***REBOOT***' >> ${LOCKFILE}
|
||||
sleep 5
|
||||
/usr/local/etc/rc.reboot
|
||||
fi
|
||||
fi
|
||||
|
||||
echo '***DONE***' >> ${PKG_PROGRESS_FILE}
|
||||
echo '***DONE***' >> ${LOCKFILE}
|
||||
|
||||
@ -25,19 +25,19 @@
|
||||
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
# POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
PKG_PROGRESS_FILE=/tmp/pkg_upgrade.progress
|
||||
LOCKFILE="/tmp/pkg_upgrade.progress"
|
||||
PIPEFILE="/tmp/pkg_upgrade.pipe"
|
||||
TEE="/usr/bin/tee -a"
|
||||
|
||||
# Truncate upgrade progress file
|
||||
: > ${PKG_PROGRESS_FILE}
|
||||
: > ${LOCKFILE}
|
||||
|
||||
echo "***GOT REQUEST TO UPGRADE***" >> ${PKG_PROGRESS_FILE}
|
||||
echo "***GOT REQUEST TO UPGRADE***" >> ${LOCKFILE}
|
||||
|
||||
# perform first half of major upgrade (download all + kernel install)
|
||||
if opnsense-update -u >> ${PKG_PROGRESS_FILE} 2>&1; then
|
||||
echo '***REBOOT***' >> ${PKG_PROGRESS_FILE}
|
||||
# give the frontend some time to figure out that a reboot is coming
|
||||
${TEE} ${LOCKFILE} < ${PIPEFILE} &
|
||||
if opnsense-update -u > ${PIPEFILE} 2>&1; then
|
||||
echo '***REBOOT***' >> ${LOCKFILE}
|
||||
sleep 5
|
||||
/usr/local/etc/rc.reboot
|
||||
fi
|
||||
|
||||
echo '***DONE***' >> ${PKG_PROGRESS_FILE}
|
||||
echo '***DONE***' >> ${LOCKFILE}
|
||||
|
||||
@ -63,7 +63,7 @@ case ${YN} in
|
||||
[yY])
|
||||
;;
|
||||
${RELEASE:-y})
|
||||
ARGS="upgrade"
|
||||
ARGS="upgrade ${RELEASE}"
|
||||
;;
|
||||
[sS])
|
||||
echo
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user