]> git.ipfire.org Git - people/teissler/ipfire-2.x.git/blame - config/rootfiles/updater/update.sh
Add dialer to updater
[people/teissler/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"
a23731d1 29KVER="2.6.23.17"
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
41if [ -e /var/ipfire/backup/update_$OLDVERSION-$NEWVERSION.tar.bz2 ]; then
45ff5fa6
AF
42 echo Moving backup to backup-old ...
43 mv -f /var/ipfire/backup/update_$OLDVERSION-$NEWVERSION.tar.bz2 \
44 /var/ipfire/backup/update_$OLDVERSION-$NEWVERSION-old.tar.bz2
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
AF
54echo var/log/rrd >> /opt/pakfire/tmp/ROOTFILES
55echo var/updatexlerator >> /opt/pakfire/tmp/ROOTFILES
bd24e1fa 56echo lib/iptables >> /opt/pakfire/tmp/ROOTFILES
761ef000
AF
57echo lib/modules >> /opt/pakfire/tmp/ROOTFILES
58echo boot >> /opt/pakfire/tmp/ROOTFILES
9b50da9d 59#
2d9ee050 60tar cjvf /var/ipfire/backup/update_$OLDVERSION-$NEWVERSION.tar.bz2 \
e3d5f630 61 -T /opt/pakfire/tmp/ROOTFILES --exclude='#*' -C / > /dev/null 2>&1
2d9ee050 62echo
4c1bf0c9 63echo Update IPfire to $NEWVERSION ...
2d9ee050 64#
159a9efd
CS
65# Delete old collectd symlink
66#
67rm -rf /etc/rc.d/rc3.d/S20collectd
68#
761ef000
AF
69# Delete squid symlink
70#
71rm -rf /etc/rc.d/rc3.d/S99squid
72#
bd24e1fa
AF
73# Delete old iptables libs...
74#
75rm -rf /lib/iptables
76#
469c9f49 77# Remove old kernel, configs, initrd, modules ...
2d9ee050 78#
469c9f49
AF
79rm -rf /boot/System.map-*
80rm -rf /boot/config-*
81rm -rf /boot/ipfirerd-*
82rm -rf /boot/vmlinuz-*
83rm -rf /lib/modules/
9b50da9d 84#
c2cd9391
CS
85# Stopping Squid
86#
87echo
88echo Stopping Squid ...
89/etc/init.d/squid stop
90#
2d9ee050
AF
91# Unpack the updated files
92#
93echo
94echo Unpack the updated files ...
4378d325 95extract_files
c2cd9391
CS
96#
97# Starting Squid
98#
99echo
100echo Starting Squid ...
101/etc/init.d/squid start
2d9ee050
AF
102#
103# Modify grub.conf
609d4fa5
AF
104#
105echo
2d9ee050 106echo Update grub configuration ...
609d4fa5 107sed -i "s|ROOT|$ROOT|g" /boot/grub/grub.conf
2d9ee050
AF
108sed -i "s|KVER|$KVER|g" /boot/grub/grub.conf
109sed -i "s|MOUNT|$MOUNT|g" /boot/grub/grub.conf
2d9ee050 110#
edd66ab6
AF
111# Made emergency - initramdisk
112#
e3d5f630
AF
113echo
114echo Create new Initramdisks ...
edd66ab6
AF
115cp -f /etc/mkinitcpio.conf /etc/mkinitcpio.conf.org
116sed -i "s| autodetect | |g" /etc/mkinitcpio.conf
e3d5f630 117mkinitcpio -k $KVER-ipfire -g /boot/ipfirerd-$KVER-emergency.img
edd66ab6
AF
118cp -f /etc/mkinitcpio.conf.org /etc/mkinitcpio.conf
119#
2d9ee050
AF
120# Made initramdisk
121#
2d9ee050
AF
122if [ "${ROOT:0:7}" == "/dev/sd" ]; then
123 # Remove ide hook if root is on sda
124 sed -i "s| ide | |g" /etc/mkinitcpio.conf
125else
126if [ "${ROOT:0:7}" == "/dev/hd" ]; then
2e95c21c 127 # Remove pata & sata hook if root is on hda
2d9ee050 128 sed -i "s| pata | |g" /etc/mkinitcpio.conf
2e95c21c 129 sed -i "s| sata | |g" /etc/mkinitcpio.conf
2d9ee050
AF
130fi
131fi
132mkinitcpio -k $KVER-ipfire -g /boot/ipfirerd-$KVER.img
fd383f41 133#mkinitcpio -k $KVER-ipfire-smp -g /boot/ipfirerd-$KVER-smp.img
2d9ee050 134#
761ef000
AF
135# ReInstall grub
136#
137grub-install --no-floppy ${ROOT::`expr length $ROOT`-1}
138#
2d9ee050
AF
139# Change version of Pakfire.conf
140#
141sed -i "s|$OLDVERSION|$NEWVERSION|g" /opt/pakfire/etc/pakfire.conf
609d4fa5
AF
142#
143# Create new issue
144#
30abd974 145echo IPFire v$NEWVERSION - www.ipfire.org > /etc/issue
609d4fa5
AF
146echo =================================== >> /etc/issue
147echo \\n running on \\s \\r \\m >> /etc/issue
9b50da9d
AF
148#
149# Update crontab
150#
151grep -v "ipacsum" /var/spool/cron/root.orig > /tmp/root.orig.tmp
152mv /tmp/root.orig.tmp /var/spool/cron/root.orig
153chmod 600 /var/spool/cron/root.orig
154chown root:cron /var/spool/cron/root.orig
155#
156# Update network-rules
157#
c76472c0
AF
158sed -i 's|"net", SYSFS{address}|"net", SYSFS{type}=="1", SYSFS{address}|g' \
159 /etc/udev/rules.d/30-persistent-network.rules
9b50da9d 160#
876667fc
AF
161# Core 17
162#
609d4fa5 163perl -e "require '/var/ipfire/lang.pl'; &Lang::BuildCacheLang"
41e27086 164perl /var/ipfire/qos/bin/migrate.pl
d7c1050e 165/var/ipfire/updatexlrator/bin/convert
876667fc 166#
88abfb83
AF
167# Delete old lm-sensor modullist...
168#
169rm -rf /etc/sysconfig/lm_sensors
170#
876667fc
AF
171# ISDN
172#
609d4fa5 173/etc/init.d/mISDN config
7795e9ba 174#
de0e9b75 175# Remove obsolete packages, update the lists and do upgrade
7795e9ba 176#
45ff5fa6 177echo '#!/bin/bash' > /tmp/remove_obsolete_paks
7795e9ba
AF
178echo 'while [ "$(ps -A | grep " update.sh")" != "" ]; do' >> /tmp/remove_obsolete_paks
179echo ' sleep 2' >> /tmp/remove_obsolete_paks
180echo 'done' >> /tmp/remove_obsolete_paks
181echo 'while [ "$(ps -A | grep " pakfire")" != "" ]; do' >> /tmp/remove_obsolete_paks
182echo ' sleep 2' >> /tmp/remove_obsolete_paks
183echo 'done' >> /tmp/remove_obsolete_paks
de0e9b75 184echo '/opt/pakfire/pakfire remove -y mpg123 subversion zaptel' >> /tmp/remove_obsolete_paks
82d8ebf1
AF
185echo '/opt/pakfire/pakfire update -y --force' >> /tmp/remove_obsolete_paks
186echo '/opt/pakfire/pakfire upgrade -y' >> /tmp/remove_obsolete_paks
469c9f49
AF
187echo '/opt/pakfire/pakfire upgrade -y' >> /tmp/remove_obsolete_paks
188echo '/opt/pakfire/pakfire upgrade -y' >> /tmp/remove_obsolete_paks
189echo 'logger -p syslog.emerg -t core-upgrade-18 "Upgrade finished. Please reboot... "' >> /tmp/remove_obsolete_paks
c76472c0 190#
7795e9ba
AF
191chmod +x /tmp/remove_obsolete_paks
192/tmp/remove_obsolete_paks &
609d4fa5 193echo
7795e9ba 194echo Please wait until pakfire has ended...
27731caa 195echo