]> git.ipfire.org Git - people/teissler/ipfire-2.x.git/blame - config/rootfiles/core/66/update.sh
updater: change 2.13 updater to core66.
[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
0338cdb0
MT
160# Regenerate ipsec configuration files.
161/srv/web/ipfire/cgi-bin/vpnmain.cgi
162
f0a4269b
AF
163#
164# Start services
165#
166/etc/init.d/squid start
167/etc/init.d/snort start
168if [ `grep "ENABLED=on" /var/ipfire/vpn/settings` ]; then
169 /etc/init.d/ipsec start
170fi
171
172#
173# Rebuild qosscript if enabled
174#
175if [ -e /var/ipfire/qos/enable ]; then
176 /usr/local/bin/qosctrl stop
177 /usr/local/bin/qosctrl generate
178 /usr/local/bin/qosctrl start
179fi
180
1f7e3a1c
MT
181# Remove preloading libsafe.
182rm -f /etc/ld.so.preload
183
f0a4269b
AF
184#
185# Modify grub.conf
186#
187echo
188echo Update grub configuration ...
189ROOT=`mount | grep " / " | cut -d" " -f1`
190
191if [ ! -z $ROOT ]; then
192 ROOTUUID=`blkid -c /dev/null -sUUID $ROOT | cut -d'"' -f2`
193fi
194
195if [ ! -z $ROOTUUID ]; then
196 sed -i "s|ROOT|UUID=$ROOTUUID|g" /boot/grub/grub.conf
197else
198 sed -i "s|ROOT|$ROOT|g" /boot/grub/grub.conf
199fi
200sed -i "s|KVER|$KVER|g" /boot/grub/grub.conf
201sed -i "s|MOUNT|$MOUNT|g" /boot/grub/grub.conf
202
203if [ "$(grep "^serial" /boot/grub/grub.conf.org)" == "" ]; then
204 echo "grub use default console ..."
205else
206 echo "grub use serial console ..."
207 sed -i -e "s|splashimage|#splashimage|g" /boot/grub/grub.conf
208 sed -i -e "s|#serial|serial|g" /boot/grub/grub.conf
209 sed -i -e "s|#terminal|terminal|g" /boot/grub/grub.conf
63a945c1 210 sed -i -e "s| panic=10 | console=ttyS0,115200n8 panic=10 |g" /boot/grub/grub.conf
f0a4269b 211fi
ee9987e8
AF
212
213#
214# ReInstall grub
215#
216grub-install --no-floppy ${ROOT::`expr length $ROOT`-1} --recheck
217
f0a4269b
AF
218#
219# Delete old lm-sensor modullist to force search at next boot
220#
221rm -rf /etc/sysconfig/lm_sensors
222
b9d4e380
AF
223#
224# Remove powerbutton loop from rc local.
225#
226sed -i "/# power button shutdown/,+3d" /etc/sysconfig/rc.local
227
f0a4269b
AF
228#
229#Update Language cache
230perl -e "require '/var/ipfire/lang.pl'; &Lang::BuildCacheLang"
231
232#
233# Remove meta's of packages that are now common...
234#
235rm -rf /opt/pakfire/db/*/meta-fontconfig
236rm -rf /opt/pakfire/db/*/meta-glib
237
b9d4e380
AF
238# Force (re)install pae kernel if pae is supported
239rm -rf /opt/pakfire/db/*/meta-linux-pae
240if [ ! "$(grep "^flags.* pae " /proc/cpuinfo)" == "" ]; then
241 echo "Name: linux-pae" > /opt/pakfire/db/installed/meta-linux-pae
242 echo "ProgVersion: 0" >> /opt/pakfire/db/installed/meta-linux-pae
243 echo "Release: 0" >> /opt/pakfire/db/installed/meta-linux-pae
244fi
245
246# Force reinstall xen kernel if it was installed
247if [ -e "/opt/pakfire/db/installed/meta-linux-xen" ]; then
248 echo "Name: linux-xen" > /opt/pakfire/db/installed/meta-linux-xen
249 echo "ProgVersion: 0" >> /opt/pakfire/db/installed/meta-linux-xen
250 echo "Release: 0" >> /opt/pakfire/db/installed/meta-linux-xen
251fi
252
f0a4269b
AF
253#
254# After pakfire has ended run it again and update the lists and do upgrade
255#
256echo '#!/bin/bash' > /tmp/pak_update
257echo 'while [ "$(ps -A | grep " update.sh")" != "" ]; do' >> /tmp/pak_update
258echo ' sleep 1' >> /tmp/pak_update
259echo 'done' >> /tmp/pak_update
260echo 'while [ "$(ps -A | grep " pakfire")" != "" ]; do' >> /tmp/pak_update
261echo ' sleep 1' >> /tmp/pak_update
262echo 'done' >> /tmp/pak_update
263echo '/opt/pakfire/pakfire update -y --force' >> /tmp/pak_update
264echo '/opt/pakfire/pakfire upgrade -y' >> /tmp/pak_update
265echo '/opt/pakfire/pakfire upgrade -y' >> /tmp/pak_update
266echo '/opt/pakfire/pakfire upgrade -y' >> /tmp/pak_update
b9d4e380
AF
267echo '/usr/bin/logger -p syslog.emerg -t ipfire "Core-upgrade finished. If you use a customized grub.cfg"' >> /tmp/pak_update
268echo '/usr/bin/logger -p syslog.emerg -t ipfire "Check it before reboot !!!"' >> /tmp/pak_update
269echo '/usr/bin/logger -p syslog.emerg -t ipfire " *** Please reboot... *** "' >> /tmp/pak_update
f0a4269b
AF
270echo 'touch /var/run/need_reboot ' >> /tmp/pak_update
271#
272chmod +x /tmp/pak_update
273/tmp/pak_update &
274
275sync
276
277#
278#Finish
279/etc/init.d/fireinfo start
280sendprofile
281
282echo
283echo Please wait until pakfire has ended...
284echo
285#Don't report the exitcode last command
286exit 0
287