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