]>
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) | |
db5b0f96 AF |
86 | # Backup old grub config |
87 | if [ -f /boot/grub/grub.conf ]; then | |
88 | cp -vf /boot/grub/grub.conf /boot/old-grub-config | |
89 | fi | |
90 | if [ -f /boot/grub/menu.lst ]; then | |
91 | cp -vf /boot/grub/menu.lst /boot/old-grub-config | |
92 | fi | |
93 | if [ -f /boot/grub/grub.cfg ]; then | |
94 | cp -vf /boot/grub/grub.cfg /boot/old-grub-config | |
95 | fi | |
77642396 MT |
96 | |
97 | # Remove all files that belong to GRUB-legacy | |
98 | rm -rfv /boot/grub | |
99 | ;; | |
8d903f6d AF |
100 | armv*) |
101 | # Backup uEnv.txt if exist | |
102 | if [ -e /boot/uEnv.txt ]; then | |
103 | cp -vf /boot/uEnv.txt /boot/uEnv.txt.org | |
104 | fi | |
105 | ||
106 | # work around the u-boot folder detection bug | |
107 | mkdir -pv /boot/dtb-$KVER-ipfire-kirkwood | |
108 | mkdir -pv /boot/dtb-$KVER-ipfire-multi | |
109 | ;; | |
77642396 | 110 | esac |
40a8ea81 | 111 | |
77642396 MT |
112 | # |
113 | #Stop services | |
114 | /etc/init.d/snort stop | |
115 | /etc/init.d/squid stop | |
116 | /etc/init.d/ipsec stop | |
117 | /etc/init.d/apache stop | |
118 | ||
119 | # | |
120 | #Extract files | |
121 | tar xavf /opt/pakfire/tmp/files* --no-overwrite-dir -p --numeric-owner -C / | |
122 | ||
bbdd37b1 AF |
123 | # |
124 | #restart init because glibc was updated. | |
75f3abe2 | 125 | telinit u |
bbdd37b1 | 126 | |
77642396 MT |
127 | # Check diskspace on boot |
128 | BOOTSPACE=`df /boot -Pk | sed "s| * | |g" | cut -d" " -f4 | tail -n 1` | |
129 | ||
130 | if [ $BOOTSPACE -lt 1000 ]; then | |
131 | case $(uname -r) in | |
132 | *-ipfire-kirkwood ) | |
133 | # Special handling for old kirkwood images. | |
134 | # (install only kirkwood kernel) | |
135 | rm -rf /boot/* | |
8d903f6d AF |
136 | # work around the u-boot folder detection bug |
137 | mkdir -pv /boot/dtb-$KVER-ipfire-kirkwood | |
77642396 MT |
138 | tar xavf /opt/pakfire/tmp/files* --no-overwrite-dir -p \ |
139 | --numeric-owner -C / --wildcards 'boot/*-kirkwood*' | |
140 | ;; | |
141 | * ) | |
142 | /usr/bin/logger -p syslog.emerg -t ipfire \ | |
143 | "core-update-${core}: FATAL-ERROR space run out on boot. System is not bootable..." | |
144 | /etc/init.d/apache start | |
145 | exit 4 | |
146 | ;; | |
147 | esac | |
148 | fi | |
c172d453 MT |
149 | |
150 | # Update Language cache | |
151 | perl -e "require '/var/ipfire/lang.pl'; &Lang::BuildCacheLang" | |
152 | ||
77642396 MT |
153 | # Add nobody to group dialout |
154 | usermod -a -G dialout nobody | |
155 | ||
156 | # | |
157 | # Start services | |
158 | # | |
159 | /etc/init.d/apache start | |
160 | /etc/init.d/squid start | |
161 | /etc/init.d/snort start | |
162 | if [ `grep "ENABLED=on" /var/ipfire/vpn/settings` ]; then | |
163 | /etc/init.d/ipsec start | |
164 | fi | |
165 | ||
166 | case "$(uname -m)" in | |
167 | i?86) | |
168 | # | |
169 | # Update to GRUB2 | |
170 | # | |
171 | echo | |
172 | echo Update grub configuration ... | |
db5b0f96 | 173 | if grep -qE "^serial" /boot/old-grub-config; then |
77642396 MT |
174 | sed -i /etc/default/grub \ |
175 | -e "s| panic=10 | console=ttyS0,115200n8 panic=10 |g" | |
176 | echo "GRUB_TERMINAL=\"serial\"" >> /etc/default/grub | |
177 | echo "GRUB_SERIAL_COMMAND=\"serial --unit=0 --speed=115200\"" >> /etc/default/grub | |
178 | fi | |
77642396 | 179 | |
ff3bae7b MT |
180 | if ! /usr/local/bin/update-bootloader; then |
181 | logger -p syslog.emerg -t ipfire \ | |
182 | "Could not update the bootloader!" | |
77642396 MT |
183 | fi |
184 | ;; | |
185 | esac | |
186 | ||
187 | # Force (re)install pae kernel if pae is supported | |
188 | rm -rf /opt/pakfire/db/*/meta-linux-pae | |
189 | if [ ! "$(grep "^flags.* pae " /proc/cpuinfo)" == "" ]; then | |
190 | ROOTSPACE=`df / -Pk | sed "s| * | |g" | cut -d" " -f4 | tail -n 1` | |
191 | BOOTSPACE=`df /boot -Pk | sed "s| * | |g" | cut -d" " -f4 | tail -n 1` | |
192 | if [ $BOOTSPACE -lt 12000 -o $ROOTSPACE -lt 90000 ]; then | |
193 | /usr/bin/logger -p syslog.emerg -t ipfire \ | |
194 | "core-update-${core}: WARNING not enough space for pae kernel." | |
195 | else | |
196 | echo "Name: linux-pae" > /opt/pakfire/db/installed/meta-linux-pae | |
197 | echo "ProgVersion: 0" >> /opt/pakfire/db/installed/meta-linux-pae | |
198 | echo "Release: 0" >> /opt/pakfire/db/installed/meta-linux-pae | |
199 | echo "Name: linux-pae" > /opt/pakfire/db/meta/meta-linux-pae | |
200 | echo "ProgVersion: 0" >> /opt/pakfire/db/meta/meta-linux-pae | |
201 | echo "Release: 0" >> /opt/pakfire/db/meta/meta-linux-pae | |
c172d453 MT |
202 | fi |
203 | fi | |
204 | ||
77642396 MT |
205 | # |
206 | # After pakfire has ended run it again and update the lists and do upgrade | |
207 | # | |
208 | echo '#!/bin/bash' > /tmp/pak_update | |
209 | echo 'while [ "$(ps -A | grep " update.sh")" != "" ]; do' >> /tmp/pak_update | |
210 | echo ' sleep 1' >> /tmp/pak_update | |
211 | echo 'done' >> /tmp/pak_update | |
212 | echo 'while [ "$(ps -A | grep " pakfire")" != "" ]; do' >> /tmp/pak_update | |
213 | echo ' sleep 1' >> /tmp/pak_update | |
214 | echo 'done' >> /tmp/pak_update | |
215 | echo '/opt/pakfire/pakfire update -y --force' >> /tmp/pak_update | |
216 | echo '/opt/pakfire/pakfire upgrade -y' >> /tmp/pak_update | |
217 | echo '/opt/pakfire/pakfire upgrade -y' >> /tmp/pak_update | |
218 | echo '/opt/pakfire/pakfire upgrade -y' >> /tmp/pak_update | |
a5b2c823 | 219 | 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 |
220 | echo '/usr/bin/logger -p syslog.emerg -t ipfire "Check it before reboot !!!"' >> /tmp/pak_update |
221 | echo '/usr/bin/logger -p syslog.emerg -t ipfire " *** Please reboot... *** "' >> /tmp/pak_update | |
222 | echo 'touch /var/run/need_reboot ' >> /tmp/pak_update | |
223 | # | |
224 | killall -KILL pak_update | |
225 | chmod +x /tmp/pak_update | |
226 | /tmp/pak_update & | |
227 | ||
c172d453 MT |
228 | sync |
229 | ||
77642396 MT |
230 | # |
231 | #Finish | |
232 | ( | |
233 | /etc/init.d/fireinfo start | |
234 | sendprofile | |
235 | ) >/dev/null 2>&1 & | |
236 | ||
237 | # Update Package list for addon installation | |
238 | /opt/pakfire/pakfire update -y --force | |
c172d453 | 239 | |
77642396 MT |
240 | echo |
241 | echo Please wait until pakfire has ended... | |
242 | echo | |
c172d453 MT |
243 | |
244 | # Don't report the exitcode last command | |
245 | exit 0 |