1
|
#!/bin/sh
|
2
|
|
3
|
/etc/rc.conf_mount_rw
|
4
|
|
5
|
PFSENSETYPE=`cat /etc/platform`
|
6
|
|
7
|
# check in two places for the old kernel type, since it could have been moved elsewhere in the upgrade process.
|
8
|
if [ -f /boot/kernel/pfsense_kernel.txt ]; then
|
9
|
OLDKERNEL=`cat /boot/kernel/pfsense_kernel.txt`
|
10
|
else
|
11
|
OLDKERNEL=`cat /tmp/pfsense_kernel.txt`
|
12
|
fi
|
13
|
|
14
|
# Massage the existing kernel into one that actually exists.
|
15
|
# Leaving old entries so we can bring back other kernels later if desired.
|
16
|
case "$OLDKERNEL" in
|
17
|
"wrap")
|
18
|
KERNELTYPE=wrap
|
19
|
;;
|
20
|
"wrap_vga")
|
21
|
KERNELTYPE=wrap_vga
|
22
|
;;
|
23
|
"Developers")
|
24
|
KERNELTYPE=SMP
|
25
|
;;
|
26
|
"UP")
|
27
|
KERNELTYPE=SMP
|
28
|
;;
|
29
|
"SMP")
|
30
|
KERNELTYPE=SMP
|
31
|
;;
|
32
|
*)
|
33
|
if [ "${PFSENSETYPE}" = "pfSense" ]; then
|
34
|
KERNELTYPE=SMP
|
35
|
elif [ "${PFSENSETYPE}" = "nanobsd" ]; then
|
36
|
KERNELTYPE=WRAP
|
37
|
fi
|
38
|
;;
|
39
|
esac
|
40
|
|
41
|
# Overwrite the old kernel type with what we're using now to reflect what is about to be written out.
|
42
|
echo ${KERNELTYPE} > /boot/kernel/pfsense_kernel.txt
|
43
|
HAVE_KERNEL=false
|
44
|
|
45
|
case "${KERNELTYPE}" in
|
46
|
"wrap")
|
47
|
if [ -f /kernels/kernel_wrap.gz ]; then
|
48
|
HAVE_KERNEL=true
|
49
|
tar xzpf /kernels/kernel_wrap.gz --exclude loader.conf -C /boot/
|
50
|
cp /etc/ttys_wrap /etc/ttys
|
51
|
fi
|
52
|
;;
|
53
|
"wrap_vga")
|
54
|
if [ -f /kernels/kernel_wrap_vga.gz ]; then
|
55
|
HAVE_KERNEL=true
|
56
|
tar xzpf /kernels/kernel_wrap_vga.gz --exclude loader.conf -C /boot/
|
57
|
fi
|
58
|
;;
|
59
|
"Developers")
|
60
|
if [ -f /kernels/kernel_Dev.gz ]; then
|
61
|
HAVE_KERNEL=true
|
62
|
tar xzpf /kernels/kernel_Dev.gz --exclude loader.conf -C /boot/
|
63
|
fi
|
64
|
;;
|
65
|
"UP")
|
66
|
if [ -f /kernels/kernel_uniprocessor.gz ]; then
|
67
|
HAVE_KERNEL=true
|
68
|
tar xzpf /kernels/kernel_uniprocessor.gz --exclude loader.conf -C /boot/
|
69
|
fi
|
70
|
;;
|
71
|
"SMP")
|
72
|
if [ -f /kernels/kernel_SMP.gz ]; then
|
73
|
HAVE_KERNEL=true
|
74
|
tar xzpf /kernels/kernel_SMP.gz --exclude loader.conf -C /boot/
|
75
|
fi
|
76
|
;;
|
77
|
esac
|
78
|
|
79
|
if [ ${HAVE_KERNEL} = "false" ]; then
|
80
|
echo "ERROR: Unable to locate a kernel upgrade file!"
|
81
|
sleep 5
|
82
|
fi
|
83
|
|
84
|
if [ $PFSENSETYPE = "pfSense" ] || [ $PFSENSETYPE = "nanobsd" ]; then
|
85
|
touch /conf/needs_package_sync
|
86
|
fi
|
87
|
|
88
|
# Detect interactive logins and display the shell
|
89
|
detect_command='[ -n "$SSH_TTY" -o "$TERM" = "cons25" ] && exec /etc/rc.initial'
|
90
|
echo "$detect_command" > $CVS_CO_DIR/root/.shrc
|
91
|
echo "$detect_command" >> $CVS_CO_DIR/root/.profile
|
92
|
|
93
|
# Now turn on or off serial console as needed
|
94
|
echo "Checking for /tmp/$1/tmp/post_upgrade_command.php... " >> /conf/upgrade_log.txt
|
95
|
if [ -x /tmp/$1/tmp/post_upgrade_command.php ]; then
|
96
|
echo "Running /tmp/$1/tmp/post_upgrade_command.php $1" >> /conf/upgrade_log.txt
|
97
|
/tmp/$1/tmp/post_upgrade_command.php $1 >> /conf/upgrade_log.txt 2>&1
|
98
|
elif [ -f /tmp/post_upgrade_command.php ]; then
|
99
|
echo "Running /tmp/post_upgrade_command.php $1" >> /conf/upgrade_log.txt
|
100
|
/tmp/post_upgrade_command.php $1
|
101
|
fi
|
102
|
|
103
|
# Remove any previous MD5 sum files
|
104
|
rm -f /root/*.md5
|
105
|
|
106
|
# File moved to pfSense php shell (pfSsh.php)
|
107
|
rm -rf /usr/local/sbin/cvs_sync.sh
|
108
|
|
109
|
if [ $PFSENSETYPE = "embedded" ]; then
|
110
|
cp /etc/ttys_wrap /etc/ttys
|
111
|
fi
|
112
|
|
113
|
if [ -f /usr/local/sbin/php ]; then
|
114
|
rm /usr/local/sbin/php
|
115
|
fi
|
116
|
|
117
|
# Fixup permissions on installed files
|
118
|
if [ "${PFSENSETYPE}" = "nanobsd" ]; then
|
119
|
MTREECHKDIR=/tmp/${1}/
|
120
|
else
|
121
|
MTREECHKDIR=/
|
122
|
fi
|
123
|
if [ -f ${MTREECHKDIR}etc/pfSense.mtree ]; then
|
124
|
/usr/sbin/mtree -U -e -q -f ${MTREECHKDIR}etc/pfSense.mtree -p ${MTREECHKDIR} > /conf/mtree.log;
|
125
|
fi;
|