]> git.ipfire.org Git - ipfire-2.x.git/blob - config/rootfiles/core/171/update.sh
fc65dd85197bb874533f7f60d1461475655f777c
[ipfire-2.x.git] / config / rootfiles / core / 171 / update.sh
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) 2022 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
27 core=171
28
29 exit_with_error() {
30 # Set last succesfull installed core.
31 echo $(($core-1)) > /opt/pakfire/db/core/mine
32 # force fsck at next boot, this may fix free space on xfs
33 touch /forcefsck
34 # don't start pakfire again at error
35 killall -KILL pak_update
36 /usr/bin/logger -p syslog.emerg -t ipfire \
37 "core-update-${core}: $1"
38 exit $2
39 }
40
41 # Remove old core updates from pakfire cache to save space...
42 for (( i=1; i<=$core; i++ )); do
43 rm -f /var/cache/pakfire/core-upgrade-*-$i.ipfire
44 done
45
46 # Stop services
47 /etc/rc.d/init.d/apache stop
48 /etc/rc.d/init.d/unbound stop
49 /etc/rc.d/init.d/squid stop
50 /usr/local/bin/openvpnctrl -k
51 /usr/local/bin/openvpnctrl -kn2n
52 /etc/rc.d/init.d/ipsec stop
53 /etc/rc.d/init.d/collectd stop
54
55 KVER="xxxKVERxxx"
56
57 # Backup uEnv.txt if exist
58 if [ -e /boot/uEnv.txt ]; then
59 cp -vf /boot/uEnv.txt /boot/uEnv.txt.org
60 fi
61
62 # Do some sanity checks prior to the kernel update
63 case $(uname -r) in
64 *-ipfire*)
65 # Ok.
66 ;;
67 *)
68 exit_with_error "ERROR cannot update. No IPFire Kernel." 1
69 ;;
70 esac
71
72 # Check diskspace on root
73 ROOTSPACE=`df / -Pk | sed "s| * | |g" | cut -d" " -f4 | tail -n 1`
74
75 if [ $ROOTSPACE -lt 100000 ]; then
76 exit_with_error "ERROR cannot update because not enough free space on root." 2
77 exit 2
78 fi
79
80 # Remove the old kernel
81 rm -rvf \
82 /boot/System.map-* \
83 /boot/config-* \
84 /boot/ipfirerd-* \
85 /boot/initramfs-* \
86 /boot/vmlinuz-* \
87 /boot/uImage-* \
88 /boot/zImage-* \
89 /boot/uInit-* \
90 /boot/dtb-* \
91 /lib/modules
92
93 # Remove files
94 rm -rvf \
95 /lib/firmware/3com/3C359.bin \
96 /lib/firmware/TDA7706_OM_v2.5.1_boot.txt \
97 /lib/firmware/TDA7706_OM_v3.0.2_boot.txt \
98 /lib/firmware/atmsar11.fw \
99 /lib/firmware/bnx2/bnx2-mips-06-4.6.16.fw \
100 /lib/firmware/bnx2/bnx2-mips-06-5.0.0.j3.fw \
101 /lib/firmware/bnx2/bnx2-mips-06-5.0.0.j6.fw \
102 /lib/firmware/bnx2/bnx2-mips-06-6.0.15.fw \
103 /lib/firmware/bnx2/bnx2-mips-06-6.2.1.fw \
104 /lib/firmware/bnx2/bnx2-mips-09-4.6.17.fw \
105 /lib/firmware/bnx2/bnx2-mips-09-5.0.0.j15.fw \
106 /lib/firmware/bnx2/bnx2-mips-09-5.0.0.j3.fw \
107 /lib/firmware/bnx2/bnx2-mips-09-5.0.0.j9.fw \
108 /lib/firmware/bnx2/bnx2-mips-09-6.0.17.fw \
109 /lib/firmware/bnx2/bnx2-mips-09-6.2.1.fw \
110 /lib/firmware/bnx2/bnx2-mips-09-6.2.1a.fw \
111 /lib/firmware/bnx2/bnx2-rv2p-06-4.6.16.fw \
112 /lib/firmware/bnx2/bnx2-rv2p-06-5.0.0.j3.fw \
113 /lib/firmware/bnx2/bnx2-rv2p-09-4.6.15.fw \
114 /lib/firmware/bnx2/bnx2-rv2p-09-5.0.0.j10.fw \
115 /lib/firmware/bnx2/bnx2-rv2p-09-5.0.0.j3.fw \
116 /lib/firmware/bnx2/bnx2-rv2p-09ax-5.0.0.j10.fw \
117 /lib/firmware/bnx2/bnx2-rv2p-09ax-5.0.0.j3.fw \
118 /lib/firmware/bnx2x-e1-4.8.53.0.fw \
119 /lib/firmware/bnx2x-e1-5.2.13.0.fw \
120 /lib/firmware/bnx2x-e1-5.2.7.0.fw \
121 /lib/firmware/bnx2x-e1h-4.8.53.0.fw \
122 /lib/firmware/bnx2x-e1h-5.2.13.0.fw \
123 /lib/firmware/bnx2x-e1h-5.2.7.0.fw \
124 /lib/firmware/bnx2x/bnx2x-e1-6.0.34.0.fw \
125 /lib/firmware/bnx2x/bnx2x-e1-6.2.5.0.fw \
126 /lib/firmware/bnx2x/bnx2x-e1-6.2.9.0.fw \
127 /lib/firmware/bnx2x/bnx2x-e1-7.0.20.0.fw \
128 /lib/firmware/bnx2x/bnx2x-e1-7.0.23.0.fw \
129 /lib/firmware/bnx2x/bnx2x-e1-7.0.29.0.fw \
130 /lib/firmware/bnx2x/bnx2x-e1-7.10.51.0.fw \
131 /lib/firmware/bnx2x/bnx2x-e1-7.12.30.0.fw \
132 /lib/firmware/bnx2x/bnx2x-e1-7.2.16.0.fw \
133 /lib/firmware/bnx2x/bnx2x-e1-7.2.51.0.fw \
134 /lib/firmware/bnx2x/bnx2x-e1-7.8.17.0.fw \
135 /lib/firmware/bnx2x/bnx2x-e1-7.8.19.0.fw \
136 /lib/firmware/bnx2x/bnx2x-e1-7.8.2.0.fw \
137 /lib/firmware/bnx2x/bnx2x-e1h-6.0.34.0.fw \
138 /lib/firmware/bnx2x/bnx2x-e1h-6.2.5.0.fw \
139 /lib/firmware/bnx2x/bnx2x-e1h-6.2.9.0.fw \
140 /lib/firmware/bnx2x/bnx2x-e1h-7.0.20.0.fw \
141 /lib/firmware/bnx2x/bnx2x-e1h-7.0.23.0.fw \
142 /lib/firmware/bnx2x/bnx2x-e1h-7.0.29.0.fw \
143 /lib/firmware/bnx2x/bnx2x-e1h-7.10.51.0.fw \
144 /lib/firmware/bnx2x/bnx2x-e1h-7.12.30.0.fw \
145 /lib/firmware/bnx2x/bnx2x-e1h-7.2.16.0.fw \
146 /lib/firmware/bnx2x/bnx2x-e1h-7.2.51.0.fw \
147 /lib/firmware/bnx2x/bnx2x-e1h-7.8.17.0.fw \
148 /lib/firmware/bnx2x/bnx2x-e1h-7.8.19.0.fw \
149 /lib/firmware/bnx2x/bnx2x-e1h-7.8.2.0.fw \
150 /lib/firmware/bnx2x/bnx2x-e2-6.0.34.0.fw \
151 /lib/firmware/bnx2x/bnx2x-e2-6.2.5.0.fw \
152 /lib/firmware/bnx2x/bnx2x-e2-6.2.9.0.fw \
153 /lib/firmware/bnx2x/bnx2x-e2-7.0.20.0.fw \
154 /lib/firmware/bnx2x/bnx2x-e2-7.0.23.0.fw \
155 /lib/firmware/bnx2x/bnx2x-e2-7.0.29.0.fw \
156 /lib/firmware/bnx2x/bnx2x-e2-7.10.51.0.fw \
157 /lib/firmware/bnx2x/bnx2x-e2-7.12.30.0.fw \
158 /lib/firmware/bnx2x/bnx2x-e2-7.2.16.0.fw \
159 /lib/firmware/bnx2x/bnx2x-e2-7.2.51.0.fw \
160 /lib/firmware/bnx2x/bnx2x-e2-7.8.17.0.fw \
161 /lib/firmware/bnx2x/bnx2x-e2-7.8.19.0.fw \
162 /lib/firmware/bnx2x/bnx2x-e2-7.8.2.0.fw \
163 /lib/firmware/cbfw-3.2.1.1.bin \
164 /lib/firmware/cbfw-3.2.3.0.bin \
165 /lib/firmware/ct2fw-3.2.1.1.bin \
166 /lib/firmware/ct2fw-3.2.3.0.bin \
167 /lib/firmware/ctfw-3.2.1.1.bin \
168 /lib/firmware/ctfw-3.2.3.0.bin \
169 /lib/firmware/intel/ice/ddp/ice-1.3.28.0.pkg \
170 /lib/firmware/intel/ibt-* \
171 /lib/firmware/intelliport2.bin \
172 /lib/firmware/mediatek/BT_RAM_CODE_MT7922_1_1_hdr.bin \
173 /lib/firmware/mediatek/BT_RAM_CODE_MT7961_1_2_hdr.bin \
174 /lib/firmware/tr_smctr.bin \
175 /usr/bin/perl5.32* \
176 /usr/lib/libbfd-2.37.so \
177 /usr/lib/libbind9-9.16.31.so \
178 /usr/lib/libdns-9.16.31.so \
179 /usr/lib/libefiboot.so.1.37 \
180 /usr/lib/libefivar.so.1.37 \
181 /usr/lib/libhogweed.so.6.4 \
182 /usr/lib/libirs-9.16.31.so \
183 /usr/lib/libisc-9.16.31.so \
184 /usr/lib/libisccc-9.16.31.so \
185 /usr/lib/libisccfg-9.16.31.so \
186 /usr/lib/libnettle.so.8.4 \
187 /usr/lib/libns-9.16.31.so \
188 /usr/lib/libopcodes-2.37.so \
189 /usr/lib/libunbound.so.8.1.18 \
190 /usr/lib/perl5/5.32* \
191 /usr/lib/perl5/site_perl/5.32*
192
193 # Extract files
194 extract_files
195
196 # update linker config
197 ldconfig
198
199 # Update Language cache
200 /usr/local/bin/update-lang-cache
201
202 # Filesytem cleanup
203 /usr/local/bin/filesystem-cleanup
204
205 # Start services
206 /etc/rc.d/init.d/collectd start
207 /etc/rc.d/init.d/unbound start
208 /etc/rc.d/init.d/apache start
209 if grep -q "ENABLED=on" /var/ipfire/ovpn/settings; then
210 /usr/local/bin/openvpnctrl -s
211 /usr/local/bin/openvpnctrl -sn2n
212 fi
213 if grep -q "ENABLED=on" /var/ipfire/vpn/settings; then
214 /etc/init.d/ipsec start
215 fi
216 if [ -f /var/ipfire/proxy/enable ]; then
217 /etc/init.d/squid start
218 fi
219
220 # Regenerate all initrds
221 dracut --regenerate-all --force
222 case "$(uname -m)" in
223 armv*)
224 mkimage -A arm -T ramdisk -C lzma -d /boot/initramfs-${KVER}-ipfire.img /boot/uInit-${KVER}-ipfire
225 rm /boot/initramfs-${KVER}-ipfire.img
226 ;;
227 aarch64)
228 mkimage -A arm64 -T ramdisk -C lzma -d /boot/initramfs-${KVER}-ipfire.img /boot/uInit-${KVER}-ipfire
229 # dont remove initramfs because grub need this to boot.
230 ;;
231 esac
232
233 # This update needs a reboot...
234 touch /var/run/need_reboot
235
236 # remove lm_sensor config after collectd was started
237 # to reserch sensors at next boot with updated kernel
238 rm -f /etc/sysconfig/lm_sensors
239
240 # Upadate Kernel version in uEnv.txt
241 if [ -e /boot/uEnv.txt ]; then
242 sed -i -e "s/KVER=.*/KVER=${KVER}/g" /boot/uEnv.txt
243 fi
244
245 # Call user update script (needed for some ARM boards)
246 if [ -e /boot/pakfire-kernel-update ]; then
247 /boot/pakfire-kernel-update ${KVER}
248 fi
249
250 # Finish
251 /etc/init.d/fireinfo start
252 sendprofile
253
254 # Update grub config to display new core version
255 if [ -e /boot/grub/grub.cfg ]; then
256 grub-mkconfig -o /boot/grub/grub.cfg
257 fi
258
259 sync
260
261 # Don't report the exitcode last command
262 exit 0