]> git.ipfire.org Git - people/pmueller/ipfire-2.x.git/blob - config/rootfiles/updater/update.sh
bf1f37410b563e7536bf8d2019d3b1333efe8120
[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.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 #
54 tar cjvf /var/ipfire/backup/update_$OLDVERSION-$NEWVERSION.tar.bz2 \
55 -T /opt/pakfire/tmp/ROOTFILES --exclude='#*' -C / > /dev/null 2>&1
56 echo
57 echo Update IPfire to $NEWVERSON ...
58 #
59 # Delete old collectd symlink
60 #
61 rm -rf /etc/rc.d/rc3.d/S20collectd
62 #
63 # Remove old kernel, configs, initrd, modules ...
64 #
65 rm -rf /boot/System.map-*
66 rm -rf /boot/config-*
67 rm -rf /boot/ipfirerd-*
68 rm -rf /boot/vmlinuz-*
69 rm -rf /lib/modules/
70 #
71 # Stopping Squid
72 #
73 echo
74 echo Stopping Squid ...
75 /etc/init.d/squid stop
76 #
77 # Unpack the updated files
78 #
79 echo
80 echo Unpack the updated files ...
81 extract_files
82 #
83 # Starting Squid
84 #
85 echo
86 echo Starting Squid ...
87 /etc/init.d/squid start
88 #
89 # Modify grub.conf
90 #
91 echo
92 echo Update grub configuration ...
93 sed -i "s|ROOT|$ROOT|g" /boot/grub/grub.conf
94 sed -i "s|KVER|$KVER|g" /boot/grub/grub.conf
95 sed -i "s|MOUNT|$MOUNT|g" /boot/grub/grub.conf
96 #
97 # Made emergency - initramdisk
98 #
99 echo
100 echo Create new Initramdisks ...
101 cp -f /etc/mkinitcpio.conf /etc/mkinitcpio.conf.org
102 sed -i "s| autodetect | |g" /etc/mkinitcpio.conf
103 mkinitcpio -k $KVER-ipfire -g /boot/ipfirerd-$KVER-emergency.img
104 cp -f /etc/mkinitcpio.conf.org /etc/mkinitcpio.conf
105 #
106 # Made initramdisk
107 #
108 if [ "${ROOT:0:7}" == "/dev/sd" ]; then
109 # Remove ide hook if root is on sda
110 sed -i "s| ide | |g" /etc/mkinitcpio.conf
111 else
112 if [ "${ROOT:0:7}" == "/dev/hd" ]; then
113 # Remove pata & sata hook if root is on hda
114 sed -i "s| pata | |g" /etc/mkinitcpio.conf
115 sed -i "s| sata | |g" /etc/mkinitcpio.conf
116 fi
117 fi
118 mkinitcpio -k $KVER-ipfire -g /boot/ipfirerd-$KVER.img
119 #mkinitcpio -k $KVER-ipfire-smp -g /boot/ipfirerd-$KVER-smp.img
120 #
121 # Change version of Pakfire.conf
122 #
123 sed -i "s|$OLDVERSION|$NEWVERSION|g" /opt/pakfire/etc/pakfire.conf
124 #
125 # Create new issue
126 #
127 echo IPFire v$NEWVERSION - www.ipfire.org > /etc/issue
128 echo =================================== >> /etc/issue
129 echo \\n running on \\s \\r \\m >> /etc/issue
130 #
131 # Update crontab
132 #
133 grep -v "ipacsum" /var/spool/cron/root.orig > /tmp/root.orig.tmp
134 mv /tmp/root.orig.tmp /var/spool/cron/root.orig
135 chmod 600 /var/spool/cron/root.orig
136 chown root:cron /var/spool/cron/root.orig
137 #
138 # Update network-rules
139 #
140 sed -i 's|"net", SYSFS{address}|"net", SYSFS{type}=="1", SYSFS{address}|g' \
141 /etc/udev/rules.d/30-persistent-network.rules
142 #
143 # Core 17 begin
144 perl -e "require '/var/ipfire/lang.pl'; &Lang::BuildCacheLang"
145 /etc/init.d/mISDN config
146 # Core 17 end
147 #
148 # Remove obsolete packages, update the lists and do upgrade
149 #
150 echo '#!/bin/bash' > /tmp/remove_obsolete_paks
151 echo 'while [ "$(ps -A | grep " update.sh")" != "" ]; do' >> /tmp/remove_obsolete_paks
152 echo ' sleep 2' >> /tmp/remove_obsolete_paks
153 echo 'done' >> /tmp/remove_obsolete_paks
154 echo 'while [ "$(ps -A | grep " pakfire")" != "" ]; do' >> /tmp/remove_obsolete_paks
155 echo ' sleep 2' >> /tmp/remove_obsolete_paks
156 echo 'done' >> /tmp/remove_obsolete_paks
157 echo '/opt/pakfire/pakfire remove -y mpg123 subversion zaptel' >> /tmp/remove_obsolete_paks
158 echo '/opt/pakfire/pakfire update -y --force' >> /tmp/remove_obsolete_paks
159 echo '/opt/pakfire/pakfire upgrade -y' >> /tmp/remove_obsolete_paks
160 echo '/opt/pakfire/pakfire upgrade -y' >> /tmp/remove_obsolete_paks
161 echo '/opt/pakfire/pakfire upgrade -y' >> /tmp/remove_obsolete_paks
162 echo 'logger -p syslog.emerg -t core-upgrade-18 "Upgrade finished. Please reboot... "' >> /tmp/remove_obsolete_paks
163 #
164 chmod +x /tmp/remove_obsolete_paks
165 /tmp/remove_obsolete_paks &
166 echo
167 echo Please wait until pakfire has ended...
168 echo