summaryrefslogtreecommitdiffstats
path: root/src/usr/local/share/pfSense/pre_upgrade_command
diff options
context:
space:
mode:
authorRenato Botelho <renato@netgate.com>2015-08-25 08:08:24 -0300
committerRenato Botelho <renato@netgate.com>2015-08-25 14:49:54 -0300
commit46bc6e545a17e77202aaf01ec0cd8d5a46567525 (patch)
tree32d18dda436ec739c67c489ceb771e8629cd926f /src/usr/local/share/pfSense/pre_upgrade_command
parent4d9801c2dbd2b3e54a39578ee62b93af66607227 (diff)
downloadpfsense-46bc6e545a17e77202aaf01ec0cd8d5a46567525.zip
pfsense-46bc6e545a17e77202aaf01ec0cd8d5a46567525.tar.gz
Move main pfSense content to src/
Diffstat (limited to 'src/usr/local/share/pfSense/pre_upgrade_command')
-rw-r--r--src/usr/local/share/pfSense/pre_upgrade_command58
1 files changed, 58 insertions, 0 deletions
diff --git a/src/usr/local/share/pfSense/pre_upgrade_command b/src/usr/local/share/pfSense/pre_upgrade_command
new file mode 100644
index 0000000..2ad365f
--- /dev/null
+++ b/src/usr/local/share/pfSense/pre_upgrade_command
@@ -0,0 +1,58 @@
+#!/bin/sh
+
+/etc/rc.conf_mount_rw
+
+# Record the previous version
+PRIOR_VERSION=`uname -r | cut -d'.' -f1`
+echo $PRIOR_VERSION > /tmp/pre_upgrade_version
+
+# De-activate sync on root filesystem. See ticket #4523
+# Back up original fstab
+/bin/cp /etc/fstab /etc/fstab.orig
+# De-activate sync on the root slice only. This will not match NanoBSD since it already has sync,noatime
+/usr/bin/sed -i '' 's/^\(\/.*[[:space:]]*\/[[:space:]]*ufs[[:space:]]*\)rw,sync\([[:space:]]*[[:digit:]][[:space:]]*[[:digit:]]\)$/\1rw\2/' /etc/fstab
+
+# Hack to workaround ticket #3749
+if [ ${PRIOR_VERSION} -le 8 ] && grep -q 'sh /etc/rc.reboot' /etc/rc.firmware; then
+ PROC=$(ps axwww | grep '/etc/rc.firmware *pfSenseupgrade')
+ PID=''
+ IMG=''
+ if [ -n "${PROC}" ]; then
+ PID=$(echo "${PROC}" | awk '{print $1}')
+ IMG=$(echo "${PROC}" | sed 's,^.*pfSenseupgrade *,,')
+ fi
+
+ if [ -n "${PID}" -a -n "${IMG}" -a -f "${IMG}" ]; then
+ cp -fp /bin/sh /tmp/sh.old
+ kill ${PID} >/dev/null 2>&1
+ kill -9 ${PID} >/dev/null 2>&1
+ sed -i '' -e 's,sh /,/tmp/sh.old /,' \
+ -e 's,/usr/sbin/mtree,/tmp/mtree.old,' /etc/rc.firmware
+ # To avoid restarting rc.firmware twice because of #4328
+ sed -i '' -e '/^restore_chflags()/, /^}/ s/mtree *-PU/mtree -P/' /etc/rc.firmware
+ /etc/rc.firmware pfSenseupgrade "${IMG}"
+ exit
+ fi
+fi
+
+# One more hack to workaround #4328
+if grep -q 'mtree *-PU' /etc/rc.firmware; then
+ PROC=$(ps axwww | grep '/etc/rc.firmware *pfSenseupgrade')
+ PID=''
+ IMG=''
+ if [ -n "${PROC}" ]; then
+ PID=$(echo "${PROC}" | awk '{print $1}')
+ IMG=$(echo "${PROC}" | sed 's,^.*pfSenseupgrade *,,')
+ fi
+
+ if [ -n "${PID}" -a -n "${IMG}" -a -f "${IMG}" ]; then
+ kill ${PID} >/dev/null 2>&1
+ kill -9 ${PID} >/dev/null 2>&1
+ sed -i '' -e '/^restore_chflags()/, /^}/ s/mtree *-PU/mtree -P/' /etc/rc.firmware
+ /etc/rc.firmware pfSenseupgrade "${IMG}"
+ exit
+ fi
+fi
+
+rm /boot/kernel/*
+
OpenPOWER on IntegriCloud