]> git.ipfire.org Git - people/pmueller/ipfire-2.x.git/blob - config/rootfiles/updater/update.sh
Made squid 2.7 stable4 for core 17
[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 OLDKERNEL=`ls /boot/vmlinuz-*-ipfire | cut -d"-" -f2 | tail -n 1`
36 #
37 echo
38 echo Update IPFire $OLDVERSION to $NEWVERSION
39 echo
40 #
41 # check if we the backup file already exist
42 if [ -e /var/ipfire/backup/update_$OLDVERSION-$NEWVERSION.tar.bz2 ]; then
43 echo Moving backup to backup-old ...
44 mv -f /var/ipfire/backup/update_$OLDVERSION-$NEWVERSION.tar.bz2 \
45 /var/ipfire/backup/update_$OLDVERSION-$NEWVERSION-old.tar.bz2
46 fi
47 echo First we made a backup of all files that was inside of the
48 echo update archive. This may take a while ...
49 # Add some files that are not in the package to backup
50 echo etc/issue >> /opt/pakfire/tmp/ROOTFILES
51 echo opt/pakfire/etc/pakfire.conf >> /opt/pakfire/tmp/ROOTFILES
52 echo var/spool/cron/root.orig >> /opt/pakfire/tmp/ROOTFILES
53 echo etc/udev/rules.d/30-persistant-network.rules >> /opt/pakfire/tmp/ROOTFILES
54 #
55 tar cjvf /var/ipfire/backup/update_$OLDVERSION-$NEWVERSION.tar.bz2 \
56 -T /opt/pakfire/tmp/ROOTFILES --exclude='#*' -C / > /dev/null 2>&1
57 echo
58 echo Update IPfire to $NEWVERSON ...
59 #
60 # Delete old collectd symlink
61 #
62 rm -rf /etc/rc.d/rc3.d/S20collectd
63 #
64 # Backup the old grub config
65 #
66 mv /boot/grub/grub.conf /boot/grub/grub-old.conf
67 #
68 # Remove the kernel modules of the new kernel (only needed if this update run
69 # over an already updated system)
70 #
71 rm -rf /lib/modules/$KVER-ipfire
72 #
73 # Stopping Squid
74 #
75 echo
76 echo Stopping Squid ...
77 /etc/init.d/squid stop
78 #
79 # Unpack the updated files
80 #
81 echo
82 echo Unpack the updated files ...
83 extract_files
84 #
85 # Starting Squid
86 #
87 echo
88 echo Starting Squid ...
89 /etc/init.d/squid start
90 #
91 # Modify grub.conf
92 #
93 echo
94 echo Update grub configuration ...
95 sed -i "s|ROOT|$ROOT|g" /boot/grub/grub.conf
96 sed -i "s|KVER|$KVER|g" /boot/grub/grub.conf
97 sed -i "s|MOUNT|$MOUNT|g" /boot/grub/grub.conf
98 echo "title Old Kernel" >> /boot/grub/grub.conf
99 echo " configfile /grub/grub-old.conf" >> /boot/grub/grub.conf
100 sed -i "s|/vmlinuz-ipfire|/vmlinuz-$OLDKERNEL-ipfire|g" /boot/grub/grub-old.conf
101 #
102 # Made emergency - initramdisk
103 #
104 echo
105 echo Create new Initramdisks ...
106 cp -f /etc/mkinitcpio.conf /etc/mkinitcpio.conf.org
107 sed -i "s| autodetect | |g" /etc/mkinitcpio.conf
108 mkinitcpio -k $KVER-ipfire -g /boot/ipfirerd-$KVER-emergency.img
109 cp -f /etc/mkinitcpio.conf.org /etc/mkinitcpio.conf
110 #
111 # Made initramdisk
112 #
113 if [ "${ROOT:0:7}" == "/dev/sd" ]; then
114 # Remove ide hook if root is on sda
115 sed -i "s| ide | |g" /etc/mkinitcpio.conf
116 else
117 if [ "${ROOT:0:7}" == "/dev/hd" ]; then
118 # Remove pata & sata hook if root is on hda
119 sed -i "s| pata | |g" /etc/mkinitcpio.conf
120 sed -i "s| sata | |g" /etc/mkinitcpio.conf
121 fi
122 fi
123 mkinitcpio -k $KVER-ipfire -g /boot/ipfirerd-$KVER.img
124 #mkinitcpio -k $KVER-ipfire-smp -g /boot/ipfirerd-$KVER-smp.img
125 #
126 # Change version of Pakfire.conf
127 #
128 sed -i "s|$OLDVERSION|$NEWVERSION|g" /opt/pakfire/etc/pakfire.conf
129 #
130 # Create new issue
131 #
132 echo IPFire v$NEWVERSION - www.ipfire.org > /etc/issue
133 echo =================================== >> /etc/issue
134 echo \\n running on \\s \\r \\m >> /etc/issue
135 #
136 # Update crontab
137 #
138 grep -v "ipacsum" /var/spool/cron/root.orig > /tmp/root.orig.tmp
139 mv /tmp/root.orig.tmp /var/spool/cron/root.orig
140 chmod 600 /var/spool/cron/root.orig
141 chown root:cron /var/spool/cron/root.orig
142 #
143 # Update network-rules
144 #
145 sed -i 's|"net", SYSFS{"address"}|"net", SYSFS{"type"}=="1", SYSFS{"address"}|g' \
146 /etc/udev/rules.d/30-persistant-network.rules
147 #
148 # Core 17 begin
149 perl -e "require '/var/ipfire/lang.pl'; &Lang::BuildCacheLang"
150 /etc/init.d/mISDN config
151 # Core 17 end
152 #
153 # Remove obsolete packages
154 #
155 echo '#!/bin/bash' > /tmp/remove_obsolete_paks
156 echo 'while [ "$(ps -A | grep " update.sh")" != "" ]; do' >> /tmp/remove_obsolete_paks
157 echo ' sleep 2' >> /tmp/remove_obsolete_paks
158 echo 'done' >> /tmp/remove_obsolete_paks
159 echo 'while [ "$(ps -A | grep " pakfire")" != "" ]; do' >> /tmp/remove_obsolete_paks
160 echo ' sleep 2' >> /tmp/remove_obsolete_paks
161 echo 'done' >> /tmp/remove_obsolete_paks
162 echo '/opt/pakfire/pakfire remove -y zaptel' >> /tmp/remove_obsolete_paks
163 echo '/opt/pakfire/pakfire update -y --force' >> /tmp/remove_obsolete_paks
164 echo '/opt/pakfire/pakfire upgrade -y' >> /tmp/remove_obsolete_paks
165 echo 'echo' >> /tmp/remove_obsolete_paks
166 echo 'echo Update to IPFire $NEWVERSION finished. Please reboot... ' >> /tmp/remove_obsolete_paks
167 echo 'echo' >> /tmp/remove_obsolete_paks
168 chmod +x /tmp/remove_obsolete_paks
169 /tmp/remove_obsolete_paks &
170 echo
171 echo Please wait until pakfire has ended...
172 echo