]> git.ipfire.org Git - people/pmueller/ipfire-2.x.git/blob - config/rootfiles/updater/update.sh
Minior Kernel Update 2.6.25.19
[people/pmueller/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.25.19"
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.gz ]; then
42 echo Moving backup to backup-old ...
43 mv -f /var/ipfire/backup/update_$OLDVERSION-$NEWVERSION.tar.gz \
44 /var/ipfire/backup/update_$OLDVERSION-$NEWVERSION-old.tar.gz
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/log/vnstat >> /opt/pakfire/tmp/ROOTFILES
56 echo var/updatexlerator >> /opt/pakfire/tmp/ROOTFILES
57 echo lib/iptables >> /opt/pakfire/tmp/ROOTFILES
58 echo lib/modules >> /opt/pakfire/tmp/ROOTFILES
59 echo boot >> /opt/pakfire/tmp/ROOTFILES
60 echo srv/web/ipfire/cgi-bin/fwhits.cgi >> /opt/pakfire/tmp/ROOTFILES
61 echo srv/web/ipfire/cgi-bin/network.cgi >> /opt/pakfire/tmp/ROOTFILES
62 echo srv/web/ipfire/cgi-bin/traffics.cgi >> /opt/pakfire/tmp/ROOTFILES
63 echo srv/web/ipfire/cgi-bin/graphs.cgi >> /opt/pakfire/tmp/ROOTFILES
64 echo srv/web/ipfire/cgi-bin/qosgraph.cgi >> /opt/pakfire/tmp/ROOTFILES
65 #
66 tar czvf /var/ipfire/backup/update_$OLDVERSION-$NEWVERSION.tar.gz \
67 -T /opt/pakfire/tmp/ROOTFILES --exclude='#*' -C / > /dev/null 2>&1
68 echo
69 echo Update IPfire to $NEWVERSION ...
70 #
71 # On some systems the folder for addon backups is missing
72 #
73 if [ ! -e /var/ipfire/backup/addons/backup ]; then
74 mkdir -p /var/ipfire/backup/addons/backup
75 fi
76 #
77 # Delete old collectd symlink
78 #
79 rm -rf /etc/rc.d/rc3.d/S20collectd
80 #
81 # Delete squid symlink
82 #
83 rm -rf /etc/rc.d/rc3.d/S99squid
84 #
85 # Delete old cgi files ...
86 #
87 rm -rf /srv/web/ipfire/cgi-bin/fwhits.cgi
88 rm -rf /srv/web/ipfire/cgi-bin/network.cgi
89 rm -rf /srv/web/ipfire/cgi-bin/traffics.cgi
90 rm -rf /srv/web/ipfire/cgi-bin/graphs.cgi
91 rm -rf /srv/web/ipfire/cgi-bin/qosgraph.cgi
92 #
93 # Delete old iptables libs...
94 #
95 rm -rf /lib/iptables
96 #
97 # Remove old kernel, configs, initrd, modules ...
98 #
99 rm -rf /boot/System.map-*
100 rm -rf /boot/config-*
101 rm -rf /boot/ipfirerd-*
102 rm -rf /boot/vmlinuz-*
103 rm -rf /lib/modules/
104 #
105 # Stopping Squid
106 #
107 echo
108 echo Stopping Squid ...
109 /etc/init.d/squid stop
110 #
111 # Unpack the updated files
112 #
113 echo
114 echo Unpack the updated files ...
115 #
116 tar xvf /opt/pakfire/tmp/files --preserve --numeric-owner -C / \
117 --no-overwrite-dir
118 #
119 # Starting Squid
120 #
121 echo
122 echo Starting Squid ...
123 /etc/init.d/squid start
124 #
125 # Modify grub.conf
126 #
127 echo
128 echo Update grub configuration ...
129 sed -i "s|ROOT|$ROOT|g" /boot/grub/grub.conf
130 sed -i "s|KVER|$KVER|g" /boot/grub/grub.conf
131 sed -i "s|MOUNT|$MOUNT|g" /boot/grub/grub.conf
132 #
133 # Made emergency - initramdisk
134 #
135 echo
136 echo Create new Initramdisks ...
137 cp -f /etc/mkinitcpio.conf /etc/mkinitcpio.conf.org
138 sed -i "s| autodetect | |g" /etc/mkinitcpio.conf
139 mkinitcpio -k $KVER-ipfire -g /boot/ipfirerd-$KVER-emergency.img
140 cp -f /etc/mkinitcpio.conf.org /etc/mkinitcpio.conf
141 #
142 # Made initramdisk
143 #
144 if [ "${ROOT:0:7}" == "/dev/sd" ]; then
145 # Remove ide hook if root is on sda
146 sed -i "s| ide | |g" /etc/mkinitcpio.conf
147 else
148 if [ "${ROOT:0:7}" == "/dev/hd" ]; then
149 # Remove pata & sata hook if root is on hda
150 sed -i "s| pata | |g" /etc/mkinitcpio.conf
151 sed -i "s| sata | |g" /etc/mkinitcpio.conf
152 fi
153 fi
154 mkinitcpio -k $KVER-ipfire -g /boot/ipfirerd-$KVER.img
155 #mkinitcpio -k $KVER-ipfire-smp -g /boot/ipfirerd-$KVER-smp.img
156 #
157 # ReInstall grub
158 #
159 grub-install --no-floppy ${ROOT::`expr length $ROOT`-1}
160 #
161 # Update fstab
162 #
163 grep -v "tmpfs" /etc/fstab > /tmp/fstab.tmp
164 echo "#none /tmp tmpfs defaults 0 0" >> /tmp/fstab.tmp
165 echo "none /var/log/rrd tmpfs defaults,size=112M 0 0" >> /tmp/fstab.tmp
166 echo "none /var/lock tmpfs defaults,size=8M 0 0" >> /tmp/fstab.tmp
167 echo "none /var/run tmpfs defaults,size=8M 0 0" >> /tmp/fstab.tmp
168 mv /tmp/fstab.tmp /etc/fstab
169 #
170 # Change version of Pakfire.conf
171 #
172 sed -i "s|$OLDVERSION|$NEWVERSION|g" /opt/pakfire/etc/pakfire.conf
173 #
174 # Create new issue
175 #
176 echo IPFire v$NEWVERSION - www.ipfire.org > /etc/issue
177 echo =================================== >> /etc/issue
178 echo \\n running on \\s \\r \\m >> /etc/issue
179 #
180 # Update crontab
181 #
182 grep -v "ipacsum" /var/spool/cron/root.orig | grep -v "hddshutdown" > /tmp/root.orig.tmp
183 echo "# Backup collectd files" >> /tmp/root.orig.tmp
184 echo "* 05 * * * /etc/init.d/tmpfs backup >/dev/null" >> /tmp/root.orig.tmp
185 echo "# hddshutdown" >> /tmp/root.orig.tmp
186 echo "*/30 * * * * /usr/local/bin/hddshutdown >/dev/null" >> /tmp/root.orig.tmp
187 mv /tmp/root.orig.tmp /var/spool/cron/root.orig
188 chmod 600 /var/spool/cron/root.orig
189 chown root:cron /var/spool/cron/root.orig
190 #
191 # Update network-rules
192 #
193 sed -i 's|"net", SYSFS{address}|"net", SYSFS{type}=="1", SYSFS{address}|g' \
194 /etc/udev/rules.d/30-persistent-network.rules
195 #
196 # Move vnstat database to /var/log/rrd
197 #
198 mkdir -p /var/log/rrd.bak/vnstat
199 mkdir -p /var/log/rrd/vnstat
200 if [ -e /var/log/vnstat ]; then
201 cp -pR /var/log/vnstat /var/log/rrd.bak/vnstat
202 mv /var/log/vnstat /var/log/rrd/vnstat
203 fi
204 #
205 # Fix qos.sh
206 #
207 sed -i 's|rmmod imq|#rmmod imq|g' /var/ipfire/qos/bin/qos.sh
208 #
209 # Core 17
210 #
211 perl -e "require '/var/ipfire/lang.pl'; &Lang::BuildCacheLang"
212 perl /var/ipfire/qos/bin/migrate.pl
213 /var/ipfire/updatexlrator/bin/convert
214 #
215 # Delete old lm-sensor modullist...
216 #
217 rm -rf /etc/sysconfig/lm_sensors
218 #
219 # ISDN
220 #
221 /etc/init.d/mISDN config
222 #
223 # Remove obsolete packages, update the lists and do upgrade
224 #
225 echo '#!/bin/bash' > /tmp/remove_obsolete_paks
226 echo 'while [ "$(ps -A | grep " update.sh")" != "" ]; do' >> /tmp/remove_obsolete_paks
227 echo ' sleep 2' >> /tmp/remove_obsolete_paks
228 echo 'done' >> /tmp/remove_obsolete_paks
229 echo 'while [ "$(ps -A | grep " pakfire")" != "" ]; do' >> /tmp/remove_obsolete_paks
230 echo ' sleep 2' >> /tmp/remove_obsolete_paks
231 echo 'done' >> /tmp/remove_obsolete_paks
232 echo '/opt/pakfire/pakfire remove -y mpg123 subversion zaptel' >> /tmp/remove_obsolete_paks
233 echo '/opt/pakfire/pakfire update -y --force' >> /tmp/remove_obsolete_paks
234 echo '/opt/pakfire/pakfire upgrade -y' >> /tmp/remove_obsolete_paks
235 echo '/opt/pakfire/pakfire upgrade -y' >> /tmp/remove_obsolete_paks
236 echo '/opt/pakfire/pakfire upgrade -y' >> /tmp/remove_obsolete_paks
237 echo 'logger -p syslog.emerg -t core-upgrade-20 "Upgrade finished. Please reboot... "' >> /tmp/remove_obsolete_paks
238 #
239 chmod +x /tmp/remove_obsolete_paks
240 /tmp/remove_obsolete_paks &
241 echo
242 echo Please wait until pakfire has ended...
243 echo