From 1c114534116b4326f6b64d977fe0461ac56fd7a2 Mon Sep 17 00:00:00 2001 From: Renato Botelho Date: Fri, 13 Nov 2015 15:26:35 -0200 Subject: Add a new option to force upgrade script to don't reboot --- src/usr/local/sbin/pfSense-upgrade | 31 ++++++++++++++++++------------- 1 file changed, 18 insertions(+), 13 deletions(-) (limited to 'src/usr/local/sbin/pfSense-upgrade') diff --git a/src/usr/local/sbin/pfSense-upgrade b/src/usr/local/sbin/pfSense-upgrade index f39a0a3..979242b 100755 --- a/src/usr/local/sbin/pfSense-upgrade +++ b/src/usr/local/sbin/pfSense-upgrade @@ -57,6 +57,7 @@ usage() { echo " -h - Show this usage help" >&2 echo " -l - Logfile path (defaults to /cf/conf/upgrade_log.txt)" >&2 echo " -p socket - Write pkg progress to socket" + echo " -R - Do not reboot (it can be dangerous)" echo " -y - Consider yes as the answer for any possible interaction" >&2 echo "" >&2 echo "Following parameters are mutually exclusive:" >&2 @@ -319,10 +320,7 @@ pkg_upgrade() { fi fi switch_active_nanobsd_partition - _echo "Upgrade is complete. Rebooting in 10 seconds." - echo "Upgrade is complete. Rebooting in 10 seconds." | wall - /etc/rc.notify_message -e -g -m "Upgrade is complete. Rebooting in 10 seconds." - (sleep 10 && /etc/rc.reboot) & + do_reboot _exit 0 fi @@ -354,10 +352,7 @@ pkg_upgrade() { next_stage=2 if [ -n "${need_reboot}" -a "${platform}" != "nanobsd" ]; then - _echo "Upgrade is complete. Rebooting in 10 seconds." - echo "Upgrade is complete. Rebooting in 10 seconds." | wall - /etc/rc.notify_message -e -g -m "Upgrade is complete. Rebooting in 10 seconds." - (sleep 10 && /etc/rc.reboot) & + do_reboot _exit 0 fi fi @@ -386,10 +381,7 @@ pkg_upgrade() { if [ -n "${need_reboot}" -a "${platform}" = "nanobsd" ]; then switch_active_nanobsd_partition - _echo "Upgrade is complete. Rebooting in 10 seconds." - echo "Upgrade is complete. Rebooting in 10 seconds." | wall - /etc/rc.notify_message -e -g -m "Upgrade is complete. Rebooting in 10 seconds." - (sleep 10 && /etc/rc.reboot) & + do_reboot _exit 0 fi @@ -612,6 +604,15 @@ pkg_reinstall_all() { done } +do_reboot() { + _echo "Upgrade is complete. Rebooting in 10 seconds." + echo "Upgrade is complete. Rebooting in 10 seconds." | wall + /etc/rc.notify_message -e -g -m "Upgrade is complete. Rebooting in 10 seconds." + if [ -z "${dont_reboot}" ]; then + (sleep 10 && /etc/rc.reboot) & + fi +} + pid_file="/var/run/$(basename $0).pid" last_update_file="/var/run/$(basename $0)-last-update" logfile="/cf/conf/upgrade_log.txt" @@ -637,6 +638,7 @@ fi export pkg_chroot="" export chroot_dir="" +unset dont_reboot unset booting unset boot_stage unset force @@ -647,7 +649,7 @@ unset action unset action_pkg unset force_ipv4 unset force_ipv6 -while getopts 46b:cdfi:hp:l:r:uy opt; do +while getopts 46b:cdfi:hp:l:r:Ruy opt; do case ${opt} in 4) if [ -n "${force_ipv6}" ]; then @@ -710,6 +712,9 @@ while getopts 46b:cdfi:hp:l:r:uy opt; do action="delete" action_pkg="${OPTARG}" ;; + R) + dont_reboot=1 + ;; u) if [ -n "${action}" ]; then usage -- cgit v1.1