]> git.ipfire.org Git - ipfire-2.x.git/blame - config/rootfiles/core/65/update.sh
ipsec: Shut up strongswan logging.
[ipfire-2.x.git] / config / rootfiles / core / 65 / update.sh
CommitLineData
f0a4269b
AF
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) 2012 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
5e307382
AF
27function add_to_backup ()
28{
29 # Add path to ROOTFILES but remove old entries to prevent double
30 # files in the tar
31 grep -v "^$1" /opt/pakfire/tmp/ROOTFILES > /opt/pakfire/tmp/ROOTFILES.tmp
32 mv /opt/pakfire/tmp/ROOTFILES.tmp /opt/pakfire/tmp/ROOTFILES
33 echo $1 >> /opt/pakfire/tmp/ROOTFILES
34}
35
f0a4269b
AF
36#
37# Remove old core updates from pakfire cache to save space...
b9d4e380
AF
38#
39# TODO: need to be corrected before release
40core=64
f0a4269b
AF
41for (( i=1; i<=$core; i++ ))
42do
43 rm -f /var/cache/pakfire/core-upgrade-*-$i.ipfire
44done
45
590bdf1b
AF
46#
47# Do some sanity checks.
590bdf1b 48if [ ! "$(mount | grep " reiser4 (")" == "" ]; then
b9d4e380
AF
49 /usr/bin/logger -p syslog.emerg -t ipfire \
50 "core-update-$core: ERROR cannot update because there is a reiser4 fs mounted."
5691eba9 51 exit 1
590bdf1b
AF
52fi
53
54#
f0a4269b 55#
01f54726 56KVER="3.2.34"
f0a4269b
AF
57MOUNT=`grep "kernel" /boot/grub/grub.conf | tail -n 1`
58# Nur den letzten Parameter verwenden
59echo $MOUNT > /dev/null
60MOUNT=$_
61if [ ! $MOUNT == "rw" ]; then
62 MOUNT="ro"
63fi
64
65#
66# check if we the backup file already exist
67if [ -e /var/ipfire/backup/core-upgrade_$KVER.tar.xz ]; then
68 echo Moving backup to backup-old ...
69 mv -f /var/ipfire/backup/core-upgrade_$KVER.tar.xz \
70 /var/ipfire/backup/core-upgrade_$KVER-old.tar.xz
71fi
72echo First we made a backup of all files that was inside of the
73echo update archive. This may take a while ...
74# Add some files that are not in the package to backup
5e307382
AF
75add_to_backup lib/modules
76add_to_backup etc/udev
77add_to_backup lib/udev
78add_to_backup boot
79add_to_backup etc/snort
80add_to_backup usr/lib/snort_*
81add_to_backup usr/share/zoneinfo
033d2763 82add_to_backup lib/libncurses*
275f872d
AF
83add_to_backup etc/dircolors
84add_to_backup etc/profile.d
85add_to_backup usr/share/terminfo
b9d4e380
AF
86add_to_backup etc/sysconfig/lm_sensors
87add_to_backup etc/sysconfig/rc.local
f0a4269b
AF
88
89# Backup the files
90tar cJvf /var/ipfire/backup/core-upgrade_$KVER.tar.xz \
91 -C / -T /opt/pakfire/tmp/ROOTFILES --exclude='#*' --exclude='/var/cache' > /dev/null 2>&1
92
b9d4e380
AF
93# Check diskspace on root
94ROOTSPACE=`df / -Pk | sed "s| * | |g" | cut -d" " -f4 | tail -n 1`
95
96if [ $ROOTSPACE -lt 70000 ]; then
97 /usr/bin/logger -p syslog.emerg -t ipfire \
98 "core-update-$core: ERROR cannot update because not enough free space on root."
99 exit 2
100fi
101
f0a4269b
AF
102echo
103echo Update Kernel to $KVER ...
104#
105# Remove old kernel, configs, initrd, modules ...
106#
107rm -rf /boot/System.map-*
108rm -rf /boot/config-*
109rm -rf /boot/ipfirerd-*
110rm -rf /boot/vmlinuz-*
1d3d1bbc
AF
111rm -rf /boot/uImage-ipfire-*
112rm -rf /boot/uInit-ipfire-*
113rm -rf /lib/modules
275f872d
AF
114rm -rf /etc/dircolors
115rm -rf /etc/profile.d
116rm -rf /usr/share/terminfo
117
f0a4269b
AF
118#
119# Remove old udev rules.
120#
5e307382
AF
121if [ -e /etc/udev/rules.d/29-ct-server-network.rules ]; then
122 cp /etc/udev/rules.d/29-ct-server-network.rules /tmp/
123fi
f0a4269b
AF
124cp /etc/udev/rules.d/30-persistent-network.rules /tmp/
125rm -rf /etc/udev
126rm -rf /lib/udev
127mkdir -p /etc/udev/rules.d
5e307382
AF
128if [ -e /tmp/rules.d/29-ct-server-network.rules ]; then
129 mv /tmp/29-ct-server-network.rules /etc/udev/rules.d/
130fi
f0a4269b
AF
131mv /tmp/30-persistent-network.rules /etc/udev/rules.d/
132
133#
134# Backup grub.conf
135#
136cp -vf /boot/grub/grub.conf /boot/grub/grub.conf.org
137
138#
139#Stop services
140/etc/init.d/snort stop
141/etc/init.d/squid stop
142/etc/init.d/ipsec stop
143
033d2763 144#Remove old snort, zoneinfo and ncurses-libs(wrong path).
f0a4269b
AF
145rm -rf /etc/snort
146rm -rf /usr/lib/snort_*
5e307382 147rm -rf /usr/share/zoneinfo
033d2763 148rm -rf /lib/libncurses*
f0a4269b
AF
149
150#
151#Extract files
5691eba9 152tar xavf /opt/pakfire/tmp/files* --no-overwrite-dir -p --numeric-owner -C /
f0a4269b
AF
153
154#
155# Start services
156#
157/etc/init.d/squid start
158/etc/init.d/snort start
159if [ `grep "ENABLED=on" /var/ipfire/vpn/settings` ]; then
160 /etc/init.d/ipsec start
161fi
162
163#
164# Rebuild qosscript if enabled
165#
166if [ -e /var/ipfire/qos/enable ]; then
167 /usr/local/bin/qosctrl stop
168 /usr/local/bin/qosctrl generate
169 /usr/local/bin/qosctrl start
170fi
171
1f7e3a1c
MT
172# Remove preloading libsafe.
173rm -f /etc/ld.so.preload
174
43f4c938
MT
175# Regenerate ipsec configuration files.
176/srv/web/ipfire/cgi-bin/vpnmain.cgi
177
f0a4269b
AF
178#
179# Modify grub.conf
180#
181echo
182echo Update grub configuration ...
183ROOT=`mount | grep " / " | cut -d" " -f1`
184
185if [ ! -z $ROOT ]; then
186 ROOTUUID=`blkid -c /dev/null -sUUID $ROOT | cut -d'"' -f2`
187fi
188
189if [ ! -z $ROOTUUID ]; then
190 sed -i "s|ROOT|UUID=$ROOTUUID|g" /boot/grub/grub.conf
191else
192 sed -i "s|ROOT|$ROOT|g" /boot/grub/grub.conf
193fi
194sed -i "s|KVER|$KVER|g" /boot/grub/grub.conf
195sed -i "s|MOUNT|$MOUNT|g" /boot/grub/grub.conf
196
197if [ "$(grep "^serial" /boot/grub/grub.conf.org)" == "" ]; then
198 echo "grub use default console ..."
199else
200 echo "grub use serial console ..."
201 sed -i -e "s|splashimage|#splashimage|g" /boot/grub/grub.conf
202 sed -i -e "s|#serial|serial|g" /boot/grub/grub.conf
203 sed -i -e "s|#terminal|terminal|g" /boot/grub/grub.conf
63a945c1 204 sed -i -e "s| panic=10 | console=ttyS0,115200n8 panic=10 |g" /boot/grub/grub.conf
f0a4269b 205fi
ee9987e8
AF
206
207#
208# ReInstall grub
209#
210grub-install --no-floppy ${ROOT::`expr length $ROOT`-1} --recheck
211
f0a4269b
AF
212#
213# Delete old lm-sensor modullist to force search at next boot
214#
215rm -rf /etc/sysconfig/lm_sensors
216
b9d4e380
AF
217#
218# Remove powerbutton loop from rc local.
219#
220sed -i "/# power button shutdown/,+3d" /etc/sysconfig/rc.local
221
f0a4269b
AF
222#
223#Update Language cache
224perl -e "require '/var/ipfire/lang.pl'; &Lang::BuildCacheLang"
225
226#
227# Remove meta's of packages that are now common...
228#
229rm -rf /opt/pakfire/db/*/meta-fontconfig
230rm -rf /opt/pakfire/db/*/meta-glib
231
b9d4e380
AF
232# Force (re)install pae kernel if pae is supported
233rm -rf /opt/pakfire/db/*/meta-linux-pae
234if [ ! "$(grep "^flags.* pae " /proc/cpuinfo)" == "" ]; then
235 echo "Name: linux-pae" > /opt/pakfire/db/installed/meta-linux-pae
236 echo "ProgVersion: 0" >> /opt/pakfire/db/installed/meta-linux-pae
237 echo "Release: 0" >> /opt/pakfire/db/installed/meta-linux-pae
238fi
239
240# Force reinstall xen kernel if it was installed
241if [ -e "/opt/pakfire/db/installed/meta-linux-xen" ]; then
242 echo "Name: linux-xen" > /opt/pakfire/db/installed/meta-linux-xen
243 echo "ProgVersion: 0" >> /opt/pakfire/db/installed/meta-linux-xen
244 echo "Release: 0" >> /opt/pakfire/db/installed/meta-linux-xen
245fi
246
f0a4269b
AF
247#
248# After pakfire has ended run it again and update the lists and do upgrade
249#
250echo '#!/bin/bash' > /tmp/pak_update
251echo 'while [ "$(ps -A | grep " update.sh")" != "" ]; do' >> /tmp/pak_update
252echo ' sleep 1' >> /tmp/pak_update
253echo 'done' >> /tmp/pak_update
254echo 'while [ "$(ps -A | grep " pakfire")" != "" ]; do' >> /tmp/pak_update
255echo ' sleep 1' >> /tmp/pak_update
256echo 'done' >> /tmp/pak_update
257echo '/opt/pakfire/pakfire update -y --force' >> /tmp/pak_update
258echo '/opt/pakfire/pakfire upgrade -y' >> /tmp/pak_update
259echo '/opt/pakfire/pakfire upgrade -y' >> /tmp/pak_update
260echo '/opt/pakfire/pakfire upgrade -y' >> /tmp/pak_update
b9d4e380
AF
261echo '/usr/bin/logger -p syslog.emerg -t ipfire "Core-upgrade finished. If you use a customized grub.cfg"' >> /tmp/pak_update
262echo '/usr/bin/logger -p syslog.emerg -t ipfire "Check it before reboot !!!"' >> /tmp/pak_update
263echo '/usr/bin/logger -p syslog.emerg -t ipfire " *** Please reboot... *** "' >> /tmp/pak_update
f0a4269b
AF
264echo 'touch /var/run/need_reboot ' >> /tmp/pak_update
265#
266chmod +x /tmp/pak_update
267/tmp/pak_update &
268
269sync
270
271#
272#Finish
273/etc/init.d/fireinfo start
274sendprofile
275
276echo
277echo Please wait until pakfire has ended...
278echo
279#Don't report the exitcode last command
280exit 0
281