]>
Commit | Line | Data |
---|---|---|
c172d453 MT |
1 | #!/bin/bash |
2 | ############################################################################ | |
3 | # # | |
4 | # This file is part of the IPFire Firewall. # | |
5 | # # | |
6 | # IPFire is free software; you can redistribute it and/or modify # | |
7 | # it under the terms of the GNU General Public License as published by # | |
8 | # the Free Software Foundation; either version 3 of the License, or # | |
9 | # (at your option) any later version. # | |
10 | # # | |
11 | # IPFire is distributed in the hope that it will be useful, # | |
12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of # | |
13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # | |
14 | # GNU General Public License for more details. # | |
15 | # # | |
16 | # You should have received a copy of the GNU General Public License # | |
17 | # along with IPFire; if not, write to the Free Software # | |
18 | # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA # | |
19 | # # | |
20 | # Copyright (C) 2014 IPFire-Team <info@ipfire.org>. # | |
21 | # # | |
22 | ############################################################################ | |
23 | # | |
24 | . /opt/pakfire/lib/functions.sh | |
25 | /usr/local/bin/backupctrl exclude >/dev/null 2>&1 | |
26 | ||
77642396 | 27 | # |
c172d453 MT |
28 | # Remove old core updates from pakfire cache to save space... |
29 | core=86 | |
77642396 | 30 | for (( i=1; i<=${core}; i++ )) |
c172d453 MT |
31 | do |
32 | rm -f /var/cache/pakfire/core-upgrade-*-$i.ipfire | |
33 | done | |
34 | ||
77642396 MT |
35 | # |
36 | # Do some sanity checks. | |
37 | case $(uname -r) in | |
38 | *-ipfire-versatile ) | |
39 | /usr/bin/logger -p syslog.emerg -t ipfire \ | |
40 | "core-update-${core}: ERROR cannot update. versatile support is dropped." | |
41 | # Report no error to pakfire. So it does not try to install it again. | |
42 | exit 0 | |
43 | ;; | |
44 | *-ipfire* ) | |
45 | # Ok. | |
46 | ;; | |
47 | * ) | |
48 | /usr/bin/logger -p syslog.emerg -t ipfire \ | |
49 | "core-update-${core}: ERROR cannot update. No IPFire Kernel." | |
50 | exit 1 | |
51 | ;; | |
52 | esac | |
c172d453 | 53 | |
c172d453 | 54 | |
77642396 MT |
55 | # |
56 | # | |
57 | KVER="xxxKVERxxx" | |
c172d453 | 58 | |
77642396 MT |
59 | # Check diskspace on root |
60 | ROOTSPACE=`df / -Pk | sed "s| * | |g" | cut -d" " -f4 | tail -n 1` | |
61 | ||
62 | if [ $ROOTSPACE -lt 100000 ]; then | |
63 | /usr/bin/logger -p syslog.emerg -t ipfire \ | |
64 | "core-update-${core}: ERROR cannot update because not enough free space on root." | |
65 | exit 2 | |
66 | fi | |
67 | ||
68 | ||
69 | echo | |
70 | echo Update Kernel to $KVER ... | |
71 | # | |
40a8ea81 | 72 | # Remove old kernel, configs, initrd, modules, dtb's ... |
77642396 MT |
73 | # |
74 | rm -rf /boot/System.map-* | |
75 | rm -rf /boot/config-* | |
76 | rm -rf /boot/ipfirerd-* | |
2b94001c | 77 | rm -rf /boot/initramfs-* |
77642396 MT |
78 | rm -rf /boot/vmlinuz-* |
79 | rm -rf /boot/uImage-ipfire-* | |
80 | rm -rf /boot/uInit-ipfire-* | |
40a8ea81 | 81 | rm -rf /boot/dtb-*-ipfire-* |
77642396 MT |
82 | rm -rf /lib/modules |
83 | ||
84 | case "$(uname -m)" in | |
85 | i?86) | |
86 | # Backup grub.conf | |
87 | cp -vf /boot/grub/grub.conf /boot/grub-legacy.conf | |
88 | ||
89 | # Remove all files that belong to GRUB-legacy | |
90 | rm -rfv /boot/grub | |
91 | ;; | |
92 | esac | |
40a8ea81 AF |
93 | # Backup uEnv.txt if exist |
94 | if [ -e /boot/uEnv.txt ]; then | |
95 | cp -vf /boot/uEnv.txt /boot/uEnv.txt.org | |
96 | fi | |
97 | ||
77642396 MT |
98 | # |
99 | #Stop services | |
100 | /etc/init.d/snort stop | |
101 | /etc/init.d/squid stop | |
102 | /etc/init.d/ipsec stop | |
103 | /etc/init.d/apache stop | |
104 | ||
105 | # | |
106 | #Extract files | |
107 | tar xavf /opt/pakfire/tmp/files* --no-overwrite-dir -p --numeric-owner -C / | |
108 | ||
bbdd37b1 AF |
109 | # |
110 | #restart init because glibc was updated. | |
75f3abe2 | 111 | telinit u |
bbdd37b1 | 112 | |
77642396 MT |
113 | # Check diskspace on boot |
114 | BOOTSPACE=`df /boot -Pk | sed "s| * | |g" | cut -d" " -f4 | tail -n 1` | |
115 | ||
116 | if [ $BOOTSPACE -lt 1000 ]; then | |
117 | case $(uname -r) in | |
118 | *-ipfire-kirkwood ) | |
119 | # Special handling for old kirkwood images. | |
120 | # (install only kirkwood kernel) | |
121 | rm -rf /boot/* | |
122 | tar xavf /opt/pakfire/tmp/files* --no-overwrite-dir -p \ | |
123 | --numeric-owner -C / --wildcards 'boot/*-kirkwood*' | |
124 | ;; | |
125 | * ) | |
126 | /usr/bin/logger -p syslog.emerg -t ipfire \ | |
127 | "core-update-${core}: FATAL-ERROR space run out on boot. System is not bootable..." | |
128 | /etc/init.d/apache start | |
129 | exit 4 | |
130 | ;; | |
131 | esac | |
132 | fi | |
c172d453 MT |
133 | |
134 | # Update Language cache | |
135 | perl -e "require '/var/ipfire/lang.pl'; &Lang::BuildCacheLang" | |
136 | ||
77642396 MT |
137 | # Add nobody to group dialout |
138 | usermod -a -G dialout nobody | |
139 | ||
140 | # | |
141 | # Start services | |
142 | # | |
143 | /etc/init.d/apache start | |
144 | /etc/init.d/squid start | |
145 | /etc/init.d/snort start | |
146 | if [ `grep "ENABLED=on" /var/ipfire/vpn/settings` ]; then | |
147 | /etc/init.d/ipsec start | |
148 | fi | |
149 | ||
150 | case "$(uname -m)" in | |
151 | i?86) | |
152 | # | |
153 | # Update to GRUB2 | |
154 | # | |
155 | echo | |
156 | echo Update grub configuration ... | |
157 | if grep -qE "^serial" /boot/grub-legacy.conf; then | |
158 | sed -i /etc/default/grub \ | |
159 | -e "s| panic=10 | console=ttyS0,115200n8 panic=10 |g" | |
160 | echo "GRUB_TERMINAL=\"serial\"" >> /etc/default/grub | |
161 | echo "GRUB_SERIAL_COMMAND=\"serial --unit=0 --speed=115200\"" >> /etc/default/grub | |
162 | fi | |
77642396 | 163 | |
ff3bae7b MT |
164 | if ! /usr/local/bin/update-bootloader; then |
165 | logger -p syslog.emerg -t ipfire \ | |
166 | "Could not update the bootloader!" | |
77642396 MT |
167 | fi |
168 | ;; | |
169 | esac | |
170 | ||
171 | # Force (re)install pae kernel if pae is supported | |
172 | rm -rf /opt/pakfire/db/*/meta-linux-pae | |
173 | if [ ! "$(grep "^flags.* pae " /proc/cpuinfo)" == "" ]; then | |
174 | ROOTSPACE=`df / -Pk | sed "s| * | |g" | cut -d" " -f4 | tail -n 1` | |
175 | BOOTSPACE=`df /boot -Pk | sed "s| * | |g" | cut -d" " -f4 | tail -n 1` | |
176 | if [ $BOOTSPACE -lt 12000 -o $ROOTSPACE -lt 90000 ]; then | |
177 | /usr/bin/logger -p syslog.emerg -t ipfire \ | |
178 | "core-update-${core}: WARNING not enough space for pae kernel." | |
179 | else | |
180 | echo "Name: linux-pae" > /opt/pakfire/db/installed/meta-linux-pae | |
181 | echo "ProgVersion: 0" >> /opt/pakfire/db/installed/meta-linux-pae | |
182 | echo "Release: 0" >> /opt/pakfire/db/installed/meta-linux-pae | |
183 | echo "Name: linux-pae" > /opt/pakfire/db/meta/meta-linux-pae | |
184 | echo "ProgVersion: 0" >> /opt/pakfire/db/meta/meta-linux-pae | |
185 | echo "Release: 0" >> /opt/pakfire/db/meta/meta-linux-pae | |
c172d453 MT |
186 | fi |
187 | fi | |
188 | ||
77642396 MT |
189 | # Force reinstall xen kernel if it was installed |
190 | if [ -e "/opt/pakfire/db/installed/meta-linux-xen" ]; then | |
191 | echo "Name: linux-xen" > /opt/pakfire/db/installed/meta-linux-xen | |
192 | echo "ProgVersion: 0" >> /opt/pakfire/db/installed/meta-linux-xen | |
193 | echo "Release: 0" >> /opt/pakfire/db/installed/meta-linux-xen | |
194 | echo "Name: linux-xen" > /opt/pakfire/db/meta/meta-linux-xen | |
195 | echo "ProgVersion: 0" >> /opt/pakfire/db/meta/meta-linux-xen | |
196 | echo "Release: 0" >> /opt/pakfire/db/meta/meta-linux-xen | |
197 | # Add xvc0 to /etc/securetty | |
198 | echo "xvc0" >> /etc/securetty | |
199 | fi | |
200 | ||
201 | # | |
202 | # After pakfire has ended run it again and update the lists and do upgrade | |
203 | # | |
204 | echo '#!/bin/bash' > /tmp/pak_update | |
205 | echo 'while [ "$(ps -A | grep " update.sh")" != "" ]; do' >> /tmp/pak_update | |
206 | echo ' sleep 1' >> /tmp/pak_update | |
207 | echo 'done' >> /tmp/pak_update | |
208 | echo 'while [ "$(ps -A | grep " pakfire")" != "" ]; do' >> /tmp/pak_update | |
209 | echo ' sleep 1' >> /tmp/pak_update | |
210 | echo 'done' >> /tmp/pak_update | |
211 | echo '/opt/pakfire/pakfire update -y --force' >> /tmp/pak_update | |
212 | echo '/opt/pakfire/pakfire upgrade -y' >> /tmp/pak_update | |
213 | echo '/opt/pakfire/pakfire upgrade -y' >> /tmp/pak_update | |
214 | echo '/opt/pakfire/pakfire upgrade -y' >> /tmp/pak_update | |
a5b2c823 | 215 | echo '/usr/bin/logger -p syslog.emerg -t ipfire "Core-upgrade finished. If you use a customized grub/uboot config"' >> /tmp/pak_update |
77642396 MT |
216 | echo '/usr/bin/logger -p syslog.emerg -t ipfire "Check it before reboot !!!"' >> /tmp/pak_update |
217 | echo '/usr/bin/logger -p syslog.emerg -t ipfire " *** Please reboot... *** "' >> /tmp/pak_update | |
218 | echo 'touch /var/run/need_reboot ' >> /tmp/pak_update | |
219 | # | |
220 | killall -KILL pak_update | |
221 | chmod +x /tmp/pak_update | |
222 | /tmp/pak_update & | |
223 | ||
c172d453 MT |
224 | sync |
225 | ||
77642396 MT |
226 | # |
227 | #Finish | |
228 | ( | |
229 | /etc/init.d/fireinfo start | |
230 | sendprofile | |
231 | ) >/dev/null 2>&1 & | |
232 | ||
233 | # Update Package list for addon installation | |
234 | /opt/pakfire/pakfire update -y --force | |
c172d453 | 235 | |
77642396 MT |
236 | echo |
237 | echo Please wait until pakfire has ended... | |
238 | echo | |
c172d453 MT |
239 | |
240 | # Don't report the exitcode last command | |
241 | exit 0 |