Skip to content

Commit

Permalink
firmware: cron-parameter ALLOW_RISKY_MAJOR_UPGRADE for auto-update; c…
Browse files Browse the repository at this point in the history
…loses #1376
  • Loading branch information
fichtner committed Jul 11, 2017
1 parent 77401d6 commit 93072dd
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
15 changes: 11 additions & 4 deletions src/etc/rc.firmware.subr
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/bin/sh

# Copyright (c) 2015-2016 Franco Fichtner <franco@opnsense.org>
# Copyright (c) 2015-2017 Franco Fichtner <franco@opnsense.org>
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
Expand Down Expand Up @@ -30,14 +30,21 @@ set -e
LOCKFILE="/tmp/pkg_upgrade.progress"
PIPEFILE="/tmp/pkg_upgrade.pipe"
TEE="/usr/bin/tee -a"
RELEASE=

if [ "${1}" = "upgrade" -a -n "${2}" ]; then
RELEASE=${2}
elif [ "${1}" = "ALLOW_RISKY_MAJOR_UPGRADE" ]; then
RELEASE=$(cat /usr/local/opnsense/firmware-upgrade 2> /dev/null)
fi

: > ${LOCKFILE}
rm -f ${PIPEFILE}
mkfifo ${PIPEFILE}

echo "***GOT REQUEST TO UPGRADE***" >> ${LOCKFILE}

if [ -z "${1}" ]; then
if [ -z "${RELEASE}" ]; then
# upgrade all packages if possible
${TEE} ${LOCKFILE} < ${PIPEFILE} &
opnsense-update -p 2>&1 > ${PIPEFILE}
Expand All @@ -55,10 +62,10 @@ if [ -z "${1}" ]; then
/usr/local/etc/rc.reboot
fi
fi
elif [ "${1}" = "upgrade" -a -n "${2}" ]; then
else
# upgrade to a major release
${TEE} ${LOCKFILE} < ${PIPEFILE} &
if opnsense-update -ur ${2} 2>&1 > ${PIPEFILE}; then
if opnsense-update -ufr ${RELEASE} 2>&1 > ${PIPEFILE}; then
echo '***REBOOT***' >> ${LOCKFILE}
sleep 5
/usr/local/etc/rc.reboot
Expand Down
2 changes: 1 addition & 1 deletion src/opnsense/service/conf/actions.d/actions_firmware.conf
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,6 @@ message:issued firmware power off
[auto-update]
command:/usr/local/etc/rc.firmware
description:Automatic firmware update
parameters:
parameters:%s
type:script
message:attempting automatic firmware update

0 comments on commit 93072dd

Please sign in to comment.