]> git.ipfire.org Git - ipfire-2.x.git/blame - config/rootfiles/core/171/update.sh
Core Update 171: Ship and rebuild crontab
[ipfire-2.x.git] / config / rootfiles / core / 171 / update.sh
CommitLineData
67eff38d
PM
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
27core=171
28
42368583
PM
29exit_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
67eff38d
PM
41# Remove old core updates from pakfire cache to save space...
42for (( i=1; i<=$core; i++ )); do
43 rm -f /var/cache/pakfire/core-upgrade-*-$i.ipfire
44done
45
46# Stop services
79fb0874 47/etc/rc.d/init.d/apache stop
64fc1360 48/etc/rc.d/init.d/unbound stop
ddbc886c 49/etc/rc.d/init.d/squid stop
492c9fb6
PM
50/usr/local/bin/openvpnctrl -k
51/usr/local/bin/openvpnctrl -kn2n
78ba0514 52/etc/rc.d/init.d/ipsec stop
b029818d 53/etc/rc.d/init.d/collectd stop
67eff38d 54
42368583
PM
55KVER="xxxKVERxxx"
56
57# Backup uEnv.txt if exist
58if [ -e /boot/uEnv.txt ]; then
59 cp -vf /boot/uEnv.txt /boot/uEnv.txt.org
60fi
61
62# Do some sanity checks prior to the kernel update
63case $(uname -r) in
64 *-ipfire*)
65 # Ok.
66 ;;
67 *)
68 exit_with_error "ERROR cannot update. No IPFire Kernel." 1
69 ;;
70esac
71
72# Check diskspace on root
73ROOTSPACE=`df / -Pk | sed "s| * | |g" | cut -d" " -f4 | tail -n 1`
74
75if [ $ROOTSPACE -lt 100000 ]; then
76 exit_with_error "ERROR cannot update because not enough free space on root." 2
77 exit 2
78fi
79
80# Remove the old kernel
81rm -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
67eff38d 93# Remove files
41a518ae 94rm -rvf \
3b01f08a
PM
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 \
8f312961 170 /lib/firmware/intel/ibt-* \
3b01f08a 171 /lib/firmware/intelliport2.bin \
8f312961
PM
172 /lib/firmware/mediatek/BT_RAM_CODE_MT7922_1_1_hdr.bin \
173 /lib/firmware/mediatek/BT_RAM_CODE_MT7961_1_2_hdr.bin \
3b01f08a 174 /lib/firmware/tr_smctr.bin \
41a518ae 175 /usr/bin/perl5.32* \
8f4b4833 176 /usr/lib/libbfd-2.37.so \
4c4953a0
PM
177 /usr/lib/libbind9-9.16.31.so \
178 /usr/lib/libdns-9.16.31.so \
1564096b
PM
179 /usr/lib/libefiboot.so.1.37 \
180 /usr/lib/libefivar.so.1.37 \
c6e683d0 181 /usr/lib/libhogweed.so.6.4 \
4c4953a0
PM
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 \
c6e683d0 186 /usr/lib/libnettle.so.8.4 \
4c4953a0 187 /usr/lib/libns-9.16.31.so \
8f4b4833 188 /usr/lib/libopcodes-2.37.so \
64fc1360 189 /usr/lib/libunbound.so.8.1.18 \
41a518ae
PM
190 /usr/lib/perl5/5.32* \
191 /usr/lib/perl5/site_perl/5.32*
67eff38d
PM
192
193# Extract files
194extract_files
195
196# update linker config
197ldconfig
198
199# Update Language cache
200/usr/local/bin/update-lang-cache
201
202# Filesytem cleanup
203/usr/local/bin/filesystem-cleanup
204
c073cb7f
PM
205# Rebuild fcrontab from scratch
206/usr/bin/fcrontab -z
207
67eff38d 208# Start services
b029818d 209/etc/rc.d/init.d/collectd start
64fc1360 210/etc/rc.d/init.d/unbound start
79fb0874 211/etc/rc.d/init.d/apache start
3ce996ff 212if grep -q "ENABLED=on" /var/ipfire/ovpn/settings; then
492c9fb6
PM
213 /usr/local/bin/openvpnctrl -s
214 /usr/local/bin/openvpnctrl -sn2n
3ce996ff 215fi
78ba0514
PM
216if grep -q "ENABLED=on" /var/ipfire/vpn/settings; then
217 /etc/init.d/ipsec start
218fi
492c9fb6 219if [ -f /var/ipfire/proxy/enable ]; then
3ce996ff
PM
220 /etc/init.d/squid start
221fi
222
42368583
PM
223# Regenerate all initrds
224dracut --regenerate-all --force
225case "$(uname -m)" in
226 armv*)
227 mkimage -A arm -T ramdisk -C lzma -d /boot/initramfs-${KVER}-ipfire.img /boot/uInit-${KVER}-ipfire
228 rm /boot/initramfs-${KVER}-ipfire.img
229 ;;
230 aarch64)
231 mkimage -A arm64 -T ramdisk -C lzma -d /boot/initramfs-${KVER}-ipfire.img /boot/uInit-${KVER}-ipfire
232 # dont remove initramfs because grub need this to boot.
233 ;;
234esac
235
67eff38d 236# This update needs a reboot...
0892c58e 237touch /var/run/need_reboot
67eff38d 238
42368583
PM
239# remove lm_sensor config after collectd was started
240# to reserch sensors at next boot with updated kernel
241rm -f /etc/sysconfig/lm_sensors
242
243# Upadate Kernel version in uEnv.txt
244if [ -e /boot/uEnv.txt ]; then
245 sed -i -e "s/KVER=.*/KVER=${KVER}/g" /boot/uEnv.txt
246fi
247
248# Call user update script (needed for some ARM boards)
249if [ -e /boot/pakfire-kernel-update ]; then
250 /boot/pakfire-kernel-update ${KVER}
251fi
252
67eff38d
PM
253# Finish
254/etc/init.d/fireinfo start
255sendprofile
256
257# Update grub config to display new core version
258if [ -e /boot/grub/grub.cfg ]; then
259 grub-mkconfig -o /boot/grub/grub.cfg
260fi
261
262sync
263
264# Don't report the exitcode last command
265exit 0