opnsense-core/tmp/pre_upgrade_command
2014-12-09 13:26:01 +01:00

31 lines
801 B
Bash

#!/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
# Hack to workaround ticket #3749
if [ "${PRIOR_VERSION}" = "8" ] && grep -q 'sh /etc/rc.reboot' /usr/local/etc/rc.firmware; then
PROC=$(ps axwww | grep '/usr/local/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 /,' /usr/local/etc/rc.firmware
/usr/local/etc/rc.firmware pfSenseupgrade "${IMG}"
exit
fi
fi
rm /boot/kernel/*