Set version to "2.7".
[people/pmueller/ipfire-2.x.git] / config / rootfiles / core / 38 / update.sh
CommitLineData
4335a594
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) 2010 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#
de167abd 27KVER="2.6.32.15"
4335a594
AF
28ROOT=`grep "root=" /boot/grub/grub.conf | cut -d"=" -f2 | cut -d" " -f1 | tail -n 1`
29MOUNT=`grep "kernel" /boot/grub/grub.conf | tail -n 1`
30# Nur den letzten Parameter verwenden
31echo $MOUNT > /dev/null
32MOUNT=$_
33if [ ! $MOUNT == "rw" ]; then
34 MOUNT="ro"
35fi
36#
37# check if we the backup file already exist
38if [ -e /var/ipfire/backup/core-upgrade_$KVER.tar.bz2 ]; then
39 echo Moving backup to backup-old ...
40 mv -f /var/ipfire/backup/core-upgrade_$KVER.tar.bz2 \
41 /var/ipfire/backup/core-upgrade_$KVER-old.tar.bz2
42fi
43echo First we made a backup of all files that was inside of the
44echo update archive. This may take a while ...
45# Add some files that are not in the package to backup
46echo lib/modules >> /opt/pakfire/tmp/ROOTFILES
47echo boot >> /opt/pakfire/tmp/ROOTFILES
48echo etc/sysconfig/lm_sensors >> /opt/pakfire/tmp/ROOTFILES
618097cb
AF
49echo usr/lib/ipsec >> /opt/pakfire/tmp/ROOTFILES
50echo usr/libexec/ipsec >> /opt/pakfire/tmp/ROOTFILES
4335a594
AF
51tar cjvf /var/ipfire/backup/core-upgrade_$KVER.tar.bz2 \
52 -C / -T /opt/pakfire/tmp/ROOTFILES --exclude='#*' > /dev/null 2>&1
c131aeaf
AF
53
54#
55# Stop Sevices
56#
57/etc/init.d/collectd stop
58/etc/init.d/squid stop
59/etc/init.d/ipsec stop
60
4335a594
AF
61echo
62echo Update Kernel to $KVER ...
63# Remove old kernel, configs, initrd, modules ...
64#
65rm -rf /boot/System.map-*
66rm -rf /boot/config-*
67rm -rf /boot/ipfirerd-*
68rm -rf /boot/vmlinuz-*
4335a594 69rm -rf /lib/modules/*-ipfire
de167abd
AF
70# Don't remove all old xen modules. Kernel may stored outside.
71# only from 2.6.27.25 and 31
72rm -rf /lib/modules/2.6.27.25-ipfire-xen
73rm -rf /lib/modules/2.6.27.31-ipfire-xen
4335a594 74#
b151637d 75# remove openswan libs ...
4335a594 76#
b151637d
AF
77rm -rf /usr/lib/ipsec
78rm -rf /usr/libexec/ipsec
4335a594
AF
79
80#
81# Backup grub.conf
82#
83cp -vf /boot/grub/grub.conf /boot/grub/grub.conf.org
84#
d2d2da10
AF
85# Stop sysklogd
86/etc/init.d/sysklogd stop
87#
4335a594
AF
88# Unpack the updated files
89#
90echo
91echo Unpack the updated files ...
92#
93tar xvf /opt/pakfire/tmp/files --preserve --numeric-owner -C / \
94 --no-overwrite-dir
95#
d2d2da10
AF
96# Start Sevices
97/etc/init.d/sysklogd start
98/etc/init.d/squid start
99#
4335a594
AF
100# Modify grub.conf
101#
102echo
103echo Update grub configuration ...
104sed -i "s|ROOT|$ROOT|g" /boot/grub/grub.conf
105sed -i "s|KVER|$KVER|g" /boot/grub/grub.conf
106sed -i "s|MOUNT|$MOUNT|g" /boot/grub/grub.conf
107
108if [ "$(grep "^serial" /boot/grub/grub.conf.org)" == "" ]; then
109 echo "grub use default console ..."
110else
111 echo "grub use serial console ..."
112 sed -i -e "s|splashimage|#splashimage|g" /boot/grub/grub.conf
113 sed -i -e "s|#serial|serial|g" /boot/grub/grub.conf
114 sed -i -e "s|#terminal|terminal|g" /boot/grub/grub.conf
115 sed -i -e "s| panic=10 | console=ttyS0,38400n8 panic=10 |g" /boot/grub/grub.conf
116fi
117#
118# Made emergency - initramdisk
119#
120echo
121echo Create new Initramdisks ...
122cp -f /etc/mkinitcpio.conf /etc/mkinitcpio.conf.org
123sed -i "s| autodetect | |g" /etc/mkinitcpio.conf
124mkinitcpio -k $KVER-ipfire -g /boot/ipfirerd-$KVER-emergency.img
125cp -f /etc/mkinitcpio.conf.org /etc/mkinitcpio.conf
126#
127# Made initramdisk
128#
129if [ "${ROOT:0:7}" == "/dev/sd" ]; then
130 # Remove ide hook if root is on sda
131 sed -i "s| ide | |g" /etc/mkinitcpio.conf
132else
133if [ "${ROOT:0:7}" == "/dev/hd" ]; then
134 # Remove pata & sata hook if root is on hda
135 sed -i "s| pata | |g" /etc/mkinitcpio.conf
136 sed -i "s| sata | |g" /etc/mkinitcpio.conf
137fi
138fi
139mkinitcpio -k $KVER-ipfire -g /boot/ipfirerd-$KVER.img
140#
141# ReInstall grub
142#
143grub-install --no-floppy ${ROOT::`expr length $ROOT`-1} --recheck
144#
145# Rebuild Language
146#
147perl -e "require '/var/ipfire/lang.pl'; &Lang::BuildCacheLang"
148#
d7cd8ad9
CS
149# Cleanup Collectd statistics...
150#
151PRECLEAN=`du -sh /var/log/rrd/collectd`
152#
153rm -rf /var/log/rrd*/collectd/localhost/processes-*/ps_count*
154rm -rf /var/log/rrd*/collectd/localhost/processes-*/ps_pagefaults*
155rm -rf /var/log/rrd*/collectd/localhost/processes-*/ps_stacksize*
156rm -rf /var/log/rrd*/collectd/localhost/processes-*/ps_state*
157rm -rf /var/log/rrd*/collectd/localhost/processes-*/ps_vm*
158#
159rm -rf /var/log/rrd*/collectd/localhost/interface/if_errors*
160rm -rf /var/log/rrd*/collectd/localhost/interface/if_packets*
161#
162rm -rf /var/log/rrd*/collectd/localhost/disk-*/disk_merged*
163rm -rf /var/log/rrd*/collectd/localhost/disk-*/disk_ops*
164rm -rf /var/log/rrd*/collectd/localhost/disk-*/disk_time*
48cad624
AF
165#
166rm -rf /var/log/rrd*/collectd/localhost/iptables-filter-INPUT/*-DROP_Wirelessinput*
167rm -rf /var/log/rrd*/collectd/localhost/iptables-filter-FORWARD/*-DROP_Wirelessforward*
168rm -rf /var/log/rrd*/collectd/localhost/iptables-filter-OUTGOINGFW
d7cd8ad9
CS
169POSTCLEAN=`du -sh /var/log/rrd/collectd`
170#
171echo Cleaned up collectd directory from $PRECLEAN to $POSTCLEAN size.
172#
d2d2da10
AF
173# Start collectd
174/etc/init.d/collectd start
175#
176# Delete old lm-sensor modullist to force search at next boot
177#
178rm -rf /etc/sysconfig/lm_sensors
179#
58fcc270
AF
180# USB Modeswitch conf now called setup, rename ...
181#
618097cb 182if [ -e /etc/usb_modeswitch.conf ]; then
58fcc270 183mv -f /etc/usb_modeswitch.conf /etc/usb_modeswitch.setup
618097cb 184fi
58fcc270 185#
618097cb
AF
186# rebuild qosscript if enabled...
187if [ -e /var/ipfire/qos/enable ]; then
188 /usr/local/bin/qosctrl stop
7d3d5dbd 189 /usr/local/bin/qosctrl generate
618097cb
AF
190 /usr/local/bin/qosctrl start
191fi
4335a594
AF
192#
193#
e3c5d22a
AF
194# convert ipsec.conf from openswan to strongswan...
195mv /var/ipfire/vpn/ipsec.conf /var/ipfire/vpn/ipsec.conf.org
196cat /var/ipfire/vpn/ipsec.conf.org | \
197grep -v "disablearrivalcheck=" | \
63249c67 198grep -v "klipsdebug=" | \
e3c5d22a 199grep -v "leftfirewall=" | \
b2d5dd6d 200grep -v "lefthostaccess=" | \
e3c5d22a
AF
201grep -v "charonstart=" | \
202grep -v "aggrmode=" > /var/ipfire/vpn/ipsec.conf
203sed -i "s|ipsec[0-9]=||g" /var/ipfire/vpn/ipsec.conf
63249c67
AF
204sed -i "s|nat_t ||g" /var/ipfire/vpn/ipsec.conf
205sed -i "s|klips ||g" /var/ipfire/vpn/ipsec.conf
b2d5dd6d 206sed -i "s|^conn [A-Za-z].*$|&\n\tleftfirewall=yes\n\tlefthostaccess=yes|g" /var/ipfire/vpn/ipsec.conf
e3c5d22a
AF
207sed -i "s|^config setup$|&\n\tcharonstart=no|g" /var/ipfire/vpn/ipsec.conf
208chown nobody:nobody /var/ipfire/vpn/ipsec.conf
209chmod 644 /var/ipfire/vpn/ipsec.conf
4335a594 210#
d2d2da10
AF
211# Add cryptodev to /etc/sysconfig/modules
212mv /etc/sysconfig/modules /etc/sysconfig/modules.org
213cat /etc/sysconfig/modules.org | \
214grep -v "cryptodev" | \
215grep -v "# End /etc/sysconfig/modules" > /etc/sysconfig/modules
216echo "" >> /etc/sysconfig/modules
217echo "### cryptodev" >> /etc/sysconfig/modules
218echo "#" >> /etc/sysconfig/modules
219echo "cryptodev" >> /etc/sysconfig/modules
220echo "" >> /etc/sysconfig/modules
221echo "# End /etc/sysconfig/modules" >> /etc/sysconfig/modules
222chmod 644 /etc/sysconfig/modules
4335a594
AF
223#
224# This core-update need a reboot
225/usr/bin/logger -p syslog.emerg -t core-upgrade-38 "Upgrade finished. If you use a customized grub.cfg"
226/usr/bin/logger -p syslog.emerg -t core-upgrade-38 "Check it before reboot !!!"
227/usr/bin/logger -p syslog.emerg -t core-upgrade-38 " *** Please reboot... *** "