]> git.ipfire.org Git - people/teissler/ipfire-2.x.git/blob - config/rootfiles/updater/update.sh
Merge branch 'master' of git://git.ipfire.org/ipfire-2.x
[people/teissler/ipfire-2.x.git] / config / rootfiles / updater / update.sh
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) 2008 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 #
27 OLDVERSION=`grep "version = " /opt/pakfire/etc/pakfire.conf | cut -d'"' -f2`
28 NEWVERSION="2.3"
29 KVER="2.6.23.17"
30 ROOT=`grep "root=" /boot/grub/grub.conf | cut -d"=" -f2 | cut -d" " -f1 | tail -n 1`
31 MOUNT=`grep "kernel" /boot/grub/grub.conf | tail -n 1`
32 # Nur den letzten Parameter verwenden
33 echo $MOUNT > /dev/null
34 MOUNT=$_
35 #
36 echo
37 echo Update IPFire $OLDVERSION to $NEWVERSION
38 echo
39 #
40 # check if we the backup file already exist
41 if [ -e /var/ipfire/backup/update_$OLDVERSION-$NEWVERSION.tar.bz2 ]; then
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
45 fi
46 echo First we made a backup of all files that was inside of the
47 echo update archive. This may take a while ...
48 # Add some files that are not in the package to backup
49 echo etc/issue >> /opt/pakfire/tmp/ROOTFILES
50 echo opt/pakfire/etc/pakfire.conf >> /opt/pakfire/tmp/ROOTFILES
51 echo var/spool/cron/root.orig >> /opt/pakfire/tmp/ROOTFILES
52 echo etc/udev/rules.d/30-persistent-network.rules >> /opt/pakfire/tmp/ROOTFILES
53 echo etc/sysconfig/lm_sensors >> /opt/pakfire/tmp/ROOTFILES
54 echo var/log/rrd >> /opt/pakfire/tmp/ROOTFILES
55 echo var/updatexlerator >> /opt/pakfire/tmp/ROOTFILES
56 echo lib/iptables >> /opt/pakfire/tmp/ROOTFILES
57 echo lib/modules >> /opt/pakfire/tmp/ROOTFILES
58 echo boot >> /opt/pakfire/tmp/ROOTFILES
59 echo srv/web/ipfire/cgi-bin/fwhits.cgi >> /opt/pakfire/tmp/ROOTFILES
60 echo srv/web/ipfire/cgi-bin/network.cgi >> /opt/pakfire/tmp/ROOTFILES
61 echo srv/web/ipfire/cgi-bin/traffics.cgi >> /opt/pakfire/tmp/ROOTFILES
62 #
63 tar cjvf /var/ipfire/backup/update_$OLDVERSION-$NEWVERSION.tar.bz2 \
64 -T /opt/pakfire/tmp/ROOTFILES --exclude='#*' -C / > /dev/null 2>&1
65 echo
66 echo Update IPfire to $NEWVERSION ...
67 #
68 # Delete old collectd symlink
69 #
70 rm -rf /etc/rc.d/rc3.d/S20collectd
71 #
72 # Delete squid symlink
73 #
74 rm -rf /etc/rc.d/rc3.d/S99squid
75 #
76 # Delete old cgi files ...
77 #
78 rm -rf /srv/web/ipfire/cgi-bin/fwhits.cgi
79 rm -rf /srv/web/ipfire/cgi-bin/network.cgi
80 rm -rf /srv/web/ipfire/cgi-bin/traffics.cgi
81 #
82 # Delete old iptables libs...
83 #
84 rm -rf /lib/iptables
85 #
86 # Remove old kernel, configs, initrd, modules ...
87 #
88 rm -rf /boot/System.map-*
89 rm -rf /boot/config-*
90 rm -rf /boot/ipfirerd-*
91 rm -rf /boot/vmlinuz-*
92 rm -rf /lib/modules/
93 #
94 # Stopping Squid
95 #
96 echo
97 echo Stopping Squid ...
98 /etc/init.d/squid stop
99 #
100 # Unpack the updated files
101 #
102 echo
103 echo Unpack the updated files ...
104 extract_files
105 #
106 # Starting Squid
107 #
108 echo
109 echo Starting Squid ...
110 /etc/init.d/squid start
111 #
112 # Modify grub.conf
113 #
114 echo
115 echo Update grub configuration ...
116 sed -i "s|ROOT|$ROOT|g" /boot/grub/grub.conf
117 sed -i "s|KVER|$KVER|g" /boot/grub/grub.conf
118 sed -i "s|MOUNT|$MOUNT|g" /boot/grub/grub.conf
119 #
120 # Made emergency - initramdisk
121 #
122 echo
123 echo Create new Initramdisks ...
124 cp -f /etc/mkinitcpio.conf /etc/mkinitcpio.conf.org
125 sed -i "s| autodetect | |g" /etc/mkinitcpio.conf
126 mkinitcpio -k $KVER-ipfire -g /boot/ipfirerd-$KVER-emergency.img
127 cp -f /etc/mkinitcpio.conf.org /etc/mkinitcpio.conf
128 #
129 # Made initramdisk
130 #
131 if [ "${ROOT:0:7}" == "/dev/sd" ]; then
132 # Remove ide hook if root is on sda
133 sed -i "s| ide | |g" /etc/mkinitcpio.conf
134 else
135 if [ "${ROOT:0:7}" == "/dev/hd" ]; then
136 # Remove pata & sata hook if root is on hda
137 sed -i "s| pata | |g" /etc/mkinitcpio.conf
138 sed -i "s| sata | |g" /etc/mkinitcpio.conf
139 fi
140 fi
141 mkinitcpio -k $KVER-ipfire -g /boot/ipfirerd-$KVER.img
142 #mkinitcpio -k $KVER-ipfire-smp -g /boot/ipfirerd-$KVER-smp.img
143 #
144 # ReInstall grub
145 #
146 grub-install --no-floppy ${ROOT::`expr length $ROOT`-1}
147 #
148 # Change version of Pakfire.conf
149 #
150 sed -i "s|$OLDVERSION|$NEWVERSION|g" /opt/pakfire/etc/pakfire.conf
151 #
152 # Create new issue
153 #
154 echo IPFire v$NEWVERSION - www.ipfire.org > /etc/issue
155 echo =================================== >> /etc/issue
156 echo \\n running on \\s \\r \\m >> /etc/issue
157 #
158 # Update crontab
159 #
160 grep -v "ipacsum" /var/spool/cron/root.orig > /tmp/root.orig.tmp
161 mv /tmp/root.orig.tmp /var/spool/cron/root.orig
162 chmod 600 /var/spool/cron/root.orig
163 chown root:cron /var/spool/cron/root.orig
164 #
165 # Update network-rules
166 #
167 sed -i 's|"net", SYSFS{address}|"net", SYSFS{type}=="1", SYSFS{address}|g' \
168 /etc/udev/rules.d/30-persistent-network.rules
169 #
170 # Core 17
171 #
172 perl -e "require '/var/ipfire/lang.pl'; &Lang::BuildCacheLang"
173 perl /var/ipfire/qos/bin/migrate.pl
174 /var/ipfire/updatexlrator/bin/convert
175 #
176 # Delete old lm-sensor modullist...
177 #
178 rm -rf /etc/sysconfig/lm_sensors
179 #
180 # ISDN
181 #
182 /etc/init.d/mISDN config
183 #
184 # Remove obsolete packages, update the lists and do upgrade
185 #
186 echo '#!/bin/bash' > /tmp/remove_obsolete_paks
187 echo 'while [ "$(ps -A | grep " update.sh")" != "" ]; do' >> /tmp/remove_obsolete_paks
188 echo ' sleep 2' >> /tmp/remove_obsolete_paks
189 echo 'done' >> /tmp/remove_obsolete_paks
190 echo 'while [ "$(ps -A | grep " pakfire")" != "" ]; do' >> /tmp/remove_obsolete_paks
191 echo ' sleep 2' >> /tmp/remove_obsolete_paks
192 echo 'done' >> /tmp/remove_obsolete_paks
193 echo '/opt/pakfire/pakfire remove -y mpg123 subversion zaptel' >> /tmp/remove_obsolete_paks
194 echo '/opt/pakfire/pakfire update -y --force' >> /tmp/remove_obsolete_paks
195 echo '/opt/pakfire/pakfire upgrade -y' >> /tmp/remove_obsolete_paks
196 echo '/opt/pakfire/pakfire upgrade -y' >> /tmp/remove_obsolete_paks
197 echo '/opt/pakfire/pakfire upgrade -y' >> /tmp/remove_obsolete_paks
198 echo 'logger -p syslog.emerg -t core-upgrade-18 "Upgrade finished. Please reboot... "' >> /tmp/remove_obsolete_paks
199 #
200 chmod +x /tmp/remove_obsolete_paks
201 /tmp/remove_obsolete_paks &
202 echo
203 echo Please wait until pakfire has ended...
204 echo