]> git.ipfire.org Git - ipfire-2.x.git/blame - config/rootfiles/updater/update.sh
Marked as 2.3 Final / core 22
[ipfire-2.x.git] / config / rootfiles / updater / update.sh
CommitLineData
2d9ee050
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 #
4378d325 8# the Free Software Foundation; either version 3 of the License, or #
2d9ee050
AF
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# #
9b50da9d 20# Copyright (C) 2008 IPFire-Team <info@ipfire.org>. #
2d9ee050
AF
21# #
22############################################################################
ff753a4c 23#
4378d325
AF
24. /opt/pakfire/lib/functions.sh
25/usr/local/bin/backupctrl exclude >/dev/null 2>&1
ff753a4c 26#
4378d325
AF
27OLDVERSION=`grep "version = " /opt/pakfire/etc/pakfire.conf | cut -d'"' -f2`
28NEWVERSION="2.3"
80e3daaf 29KVER="2.6.25.19"
2d9ee050
AF
30ROOT=`grep "root=" /boot/grub/grub.conf | cut -d"=" -f2 | cut -d" " -f1 | tail -n 1`
31MOUNT=`grep "kernel" /boot/grub/grub.conf | tail -n 1`
32# Nur den letzten Parameter verwenden
33echo $MOUNT > /dev/null
34MOUNT=$_
2d9ee050 35#
2d9ee050 36echo
609d4fa5 37echo Update IPFire $OLDVERSION to $NEWVERSION
2d9ee050 38echo
2d9ee050
AF
39#
40# check if we the backup file already exist
6689ee32 41if [ -e /var/ipfire/backup/update_$OLDVERSION-$NEWVERSION.tar.gz ]; then
45ff5fa6 42 echo Moving backup to backup-old ...
6689ee32
AF
43 mv -f /var/ipfire/backup/update_$OLDVERSION-$NEWVERSION.tar.gz \
44 /var/ipfire/backup/update_$OLDVERSION-$NEWVERSION-old.tar.gz
2d9ee050
AF
45fi
46echo First we made a backup of all files that was inside of the
47echo update archive. This may take a while ...
9b50da9d 48# Add some files that are not in the package to backup
e3d5f630
AF
49echo etc/issue >> /opt/pakfire/tmp/ROOTFILES
50echo opt/pakfire/etc/pakfire.conf >> /opt/pakfire/tmp/ROOTFILES
9b50da9d 51echo var/spool/cron/root.orig >> /opt/pakfire/tmp/ROOTFILES
c76472c0 52echo etc/udev/rules.d/30-persistent-network.rules >> /opt/pakfire/tmp/ROOTFILES
4c1bf0c9 53echo etc/sysconfig/lm_sensors >> /opt/pakfire/tmp/ROOTFILES
3b6f5eb1 54echo var/log/rrd >> /opt/pakfire/tmp/ROOTFILES
6689ee32 55echo var/log/vnstat >> /opt/pakfire/tmp/ROOTFILES
3b6f5eb1 56echo var/updatexlerator >> /opt/pakfire/tmp/ROOTFILES
bd24e1fa 57echo lib/iptables >> /opt/pakfire/tmp/ROOTFILES
761ef000
AF
58echo lib/modules >> /opt/pakfire/tmp/ROOTFILES
59echo boot >> /opt/pakfire/tmp/ROOTFILES
168a6840
AF
60echo srv/web/ipfire/cgi-bin/fwhits.cgi >> /opt/pakfire/tmp/ROOTFILES
61echo srv/web/ipfire/cgi-bin/network.cgi >> /opt/pakfire/tmp/ROOTFILES
62echo srv/web/ipfire/cgi-bin/traffics.cgi >> /opt/pakfire/tmp/ROOTFILES
bcad0fd0
CS
63echo srv/web/ipfire/cgi-bin/graphs.cgi >> /opt/pakfire/tmp/ROOTFILES
64echo srv/web/ipfire/cgi-bin/qosgraph.cgi >> /opt/pakfire/tmp/ROOTFILES
9b50da9d 65#
6689ee32 66tar czvf /var/ipfire/backup/update_$OLDVERSION-$NEWVERSION.tar.gz \
e3d5f630 67 -T /opt/pakfire/tmp/ROOTFILES --exclude='#*' -C / > /dev/null 2>&1
2d9ee050 68echo
4c1bf0c9 69echo Update IPfire to $NEWVERSION ...
2d9ee050 70#
dd7d74eb
AF
71# On some systems the folder for addon backups is missing
72#
73if [ ! -e /var/ipfire/backup/addons/backup ]; then
74 mkdir -p /var/ipfire/backup/addons/backup
75fi
76#
159a9efd
CS
77# Delete old collectd symlink
78#
79rm -rf /etc/rc.d/rc3.d/S20collectd
80#
761ef000
AF
81# Delete squid symlink
82#
83rm -rf /etc/rc.d/rc3.d/S99squid
84#
168a6840
AF
85# Delete old cgi files ...
86#
87rm -rf /srv/web/ipfire/cgi-bin/fwhits.cgi
88rm -rf /srv/web/ipfire/cgi-bin/network.cgi
89rm -rf /srv/web/ipfire/cgi-bin/traffics.cgi
bcad0fd0
CS
90rm -rf /srv/web/ipfire/cgi-bin/graphs.cgi
91rm -rf /srv/web/ipfire/cgi-bin/qosgraph.cgi
168a6840 92#
bd24e1fa
AF
93# Delete old iptables libs...
94#
95rm -rf /lib/iptables
96#
469c9f49 97# Remove old kernel, configs, initrd, modules ...
2d9ee050 98#
469c9f49
AF
99rm -rf /boot/System.map-*
100rm -rf /boot/config-*
101rm -rf /boot/ipfirerd-*
102rm -rf /boot/vmlinuz-*
103rm -rf /lib/modules/
9b50da9d 104#
c2cd9391
CS
105# Stopping Squid
106#
107echo
108echo Stopping Squid ...
109/etc/init.d/squid stop
110#
2d9ee050
AF
111# Unpack the updated files
112#
113echo
114echo Unpack the updated files ...
458f04f2
AF
115#
116tar xvf /opt/pakfire/tmp/files --preserve --numeric-owner -C / \
117 --no-overwrite-dir
c2cd9391
CS
118#
119# Starting Squid
120#
121echo
122echo Starting Squid ...
123/etc/init.d/squid start
2d9ee050
AF
124#
125# Modify grub.conf
609d4fa5
AF
126#
127echo
2d9ee050 128echo Update grub configuration ...
609d4fa5 129sed -i "s|ROOT|$ROOT|g" /boot/grub/grub.conf
2d9ee050
AF
130sed -i "s|KVER|$KVER|g" /boot/grub/grub.conf
131sed -i "s|MOUNT|$MOUNT|g" /boot/grub/grub.conf
2d9ee050 132#
edd66ab6
AF
133# Made emergency - initramdisk
134#
e3d5f630
AF
135echo
136echo Create new Initramdisks ...
edd66ab6
AF
137cp -f /etc/mkinitcpio.conf /etc/mkinitcpio.conf.org
138sed -i "s| autodetect | |g" /etc/mkinitcpio.conf
e3d5f630 139mkinitcpio -k $KVER-ipfire -g /boot/ipfirerd-$KVER-emergency.img
edd66ab6
AF
140cp -f /etc/mkinitcpio.conf.org /etc/mkinitcpio.conf
141#
2d9ee050
AF
142# Made initramdisk
143#
2d9ee050
AF
144if [ "${ROOT:0:7}" == "/dev/sd" ]; then
145 # Remove ide hook if root is on sda
146 sed -i "s| ide | |g" /etc/mkinitcpio.conf
147else
148if [ "${ROOT:0:7}" == "/dev/hd" ]; then
2e95c21c 149 # Remove pata & sata hook if root is on hda
2d9ee050 150 sed -i "s| pata | |g" /etc/mkinitcpio.conf
2e95c21c 151 sed -i "s| sata | |g" /etc/mkinitcpio.conf
2d9ee050
AF
152fi
153fi
154mkinitcpio -k $KVER-ipfire -g /boot/ipfirerd-$KVER.img
fd383f41 155#mkinitcpio -k $KVER-ipfire-smp -g /boot/ipfirerd-$KVER-smp.img
2d9ee050 156#
761ef000
AF
157# ReInstall grub
158#
159grub-install --no-floppy ${ROOT::`expr length $ROOT`-1}
160#
a4c0594b
AF
161# Update fstab
162#
163grep -v "tmpfs" /etc/fstab > /tmp/fstab.tmp
965f4547 164echo "#none /tmp tmpfs defaults 0 0" >> /tmp/fstab.tmp
f418a984
AF
165echo "none /var/log/rrd tmpfs defaults,size=112M 0 0" >> /tmp/fstab.tmp
166echo "none /var/lock tmpfs defaults,size=8M 0 0" >> /tmp/fstab.tmp
167echo "none /var/run tmpfs defaults,size=8M 0 0" >> /tmp/fstab.tmp
a4c0594b
AF
168mv /tmp/fstab.tmp /etc/fstab
169#
2d9ee050
AF
170# Change version of Pakfire.conf
171#
172sed -i "s|$OLDVERSION|$NEWVERSION|g" /opt/pakfire/etc/pakfire.conf
609d4fa5
AF
173#
174# Create new issue
175#
30abd974 176echo IPFire v$NEWVERSION - www.ipfire.org > /etc/issue
609d4fa5
AF
177echo =================================== >> /etc/issue
178echo \\n running on \\s \\r \\m >> /etc/issue
9b50da9d
AF
179#
180# Update crontab
181#
20f92a61 182grep -v "ipacsum" /var/spool/cron/root.orig | grep -v "hddshutdown" > /tmp/root.orig.tmp
7d0027bc 183echo "# Backup collectd files" >> /tmp/root.orig.tmp
1bc535b6 184echo "* 05 * * * /etc/init.d/tmpfs backup >/dev/null" >> /tmp/root.orig.tmp
20f92a61 185echo "# hddshutdown" >> /tmp/root.orig.tmp
6689ee32 186echo "*/30 * * * * /usr/local/bin/hddshutdown >/dev/null" >> /tmp/root.orig.tmp
9b50da9d
AF
187mv /tmp/root.orig.tmp /var/spool/cron/root.orig
188chmod 600 /var/spool/cron/root.orig
189chown root:cron /var/spool/cron/root.orig
190#
191# Update network-rules
192#
c76472c0
AF
193sed -i 's|"net", SYSFS{address}|"net", SYSFS{type}=="1", SYSFS{address}|g' \
194 /etc/udev/rules.d/30-persistent-network.rules
9b50da9d 195#
6689ee32
AF
196# Move vnstat database to /var/log/rrd
197#
198mkdir -p /var/log/rrd.bak/vnstat
0983dc32 199mkdir -p /var/log/rrd/vnstat
dd7d74eb 200if [ -e /var/log/vnstat ]; then
982f9d55 201 cp -pR /var/log/vnstat /var/log/rrd.bak/vnstat
dd7d74eb
AF
202 mv /var/log/vnstat /var/log/rrd/vnstat
203fi
6689ee32 204#
f418a984
AF
205# Fix qos.sh
206#
207sed -i 's|rmmod imq|#rmmod imq|g' /var/ipfire/qos/bin/qos.sh
208#
982f9d55
AF
209# Core 17
210#
211perl -e "require '/var/ipfire/lang.pl'; &Lang::BuildCacheLang"
212perl /var/ipfire/qos/bin/migrate.pl
213/var/ipfire/updatexlrator/bin/convert
214#
88abfb83
AF
215# Delete old lm-sensor modullist...
216#
217rm -rf /etc/sysconfig/lm_sensors
218#
876667fc
AF
219# ISDN
220#
609d4fa5 221/etc/init.d/mISDN config
7795e9ba 222#
de0e9b75 223# Remove obsolete packages, update the lists and do upgrade
7795e9ba 224#
45ff5fa6 225echo '#!/bin/bash' > /tmp/remove_obsolete_paks
7795e9ba
AF
226echo 'while [ "$(ps -A | grep " update.sh")" != "" ]; do' >> /tmp/remove_obsolete_paks
227echo ' sleep 2' >> /tmp/remove_obsolete_paks
228echo 'done' >> /tmp/remove_obsolete_paks
229echo 'while [ "$(ps -A | grep " pakfire")" != "" ]; do' >> /tmp/remove_obsolete_paks
230echo ' sleep 2' >> /tmp/remove_obsolete_paks
231echo 'done' >> /tmp/remove_obsolete_paks
de0e9b75 232echo '/opt/pakfire/pakfire remove -y mpg123 subversion zaptel' >> /tmp/remove_obsolete_paks
82d8ebf1
AF
233echo '/opt/pakfire/pakfire update -y --force' >> /tmp/remove_obsolete_paks
234echo '/opt/pakfire/pakfire upgrade -y' >> /tmp/remove_obsolete_paks
469c9f49
AF
235echo '/opt/pakfire/pakfire upgrade -y' >> /tmp/remove_obsolete_paks
236echo '/opt/pakfire/pakfire upgrade -y' >> /tmp/remove_obsolete_paks
3df6d96c 237echo 'logger -p syslog.emerg -t core-upgrade-22 "Upgrade finished. Please reboot... "' >> /tmp/remove_obsolete_paks
c76472c0 238#
7795e9ba
AF
239chmod +x /tmp/remove_obsolete_paks
240/tmp/remove_obsolete_paks &
609d4fa5 241echo
7795e9ba 242echo Please wait until pakfire has ended...
27731caa 243echo