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