1
|
#!/bin/sh
|
2
|
|
3
|
/etc/rc.conf_mount_rw
|
4
|
|
5
|
# Record the previous version
|
6
|
PRIOR_VERSION=`uname -r | cut -d'.' -f1`
|
7
|
echo $PRIOR_VERSION > /tmp/pre_upgrade_version
|
8
|
|
9
|
# Activate sync on root filesystem. See ticket #4523
|
10
|
# Back up original fstab
|
11
|
/bin/cp /etc/fstab /etc/fstab.orig
|
12
|
# Activate sync on the root slice only. This will not match NanoBSD since it already has sync,noatime
|
13
|
/usr/bin/sed -i '' 's/^\(\/.*[[:space:]]*\/[[:space:]]*ufs[[:space:]]*\)rw\([[:space:]]*[[:digit:]][[:space:]]*[[:digit:]]\)$/\1rw,sync\2/' /etc/fstab
|
14
|
|
15
|
# Hack to workaround ticket #3749
|
16
|
if [ ${PRIOR_VERSION} -le 8 ] && grep -q 'sh /etc/rc.reboot' /etc/rc.firmware; then
|
17
|
PROC=$(ps axwww | grep '/etc/rc.firmware *pfSenseupgrade')
|
18
|
PID=''
|
19
|
IMG=''
|
20
|
if [ -n "${PROC}" ]; then
|
21
|
PID=$(echo "${PROC}" | awk '{print $1}')
|
22
|
IMG=$(echo "${PROC}" | sed 's,^.*pfSenseupgrade *,,')
|
23
|
fi
|
24
|
|
25
|
if [ -n "${PID}" -a -n "${IMG}" -a -f "${IMG}" ]; then
|
26
|
cp -fp /bin/sh /tmp/sh.old
|
27
|
kill ${PID} >/dev/null 2>&1
|
28
|
kill -9 ${PID} >/dev/null 2>&1
|
29
|
sed -i '' -e 's,sh /,/tmp/sh.old /,' /etc/rc.firmware
|
30
|
# To avoid restarting rc.firmware twice because of #4328
|
31
|
sed -i '' -e '/^restore_chflags()/, /^}/ s/mtree *-PU/mtree -P/' /etc/rc.firmware
|
32
|
/etc/rc.firmware pfSenseupgrade "${IMG}"
|
33
|
exit
|
34
|
fi
|
35
|
fi
|
36
|
|
37
|
# One more hack to workaround #4328
|
38
|
if grep -q 'mtree *-PU' /etc/rc.firmware; then
|
39
|
PROC=$(ps axwww | grep '/etc/rc.firmware *pfSenseupgrade')
|
40
|
PID=''
|
41
|
IMG=''
|
42
|
if [ -n "${PROC}" ]; then
|
43
|
PID=$(echo "${PROC}" | awk '{print $1}')
|
44
|
IMG=$(echo "${PROC}" | sed 's,^.*pfSenseupgrade *,,')
|
45
|
fi
|
46
|
|
47
|
if [ -n "${PID}" -a -n "${IMG}" -a -f "${IMG}" ]; then
|
48
|
kill ${PID} >/dev/null 2>&1
|
49
|
kill -9 ${PID} >/dev/null 2>&1
|
50
|
sed -i '' -e '/^restore_chflags()/, /^}/ s/mtree *-PU/mtree -P/' /etc/rc.firmware
|
51
|
/etc/rc.firmware pfSenseupgrade "${IMG}"
|
52
|
exit
|
53
|
fi
|
54
|
fi
|
55
|
|
56
|
rm /boot/kernel/*
|
57
|
|