]> git.ipfire.org Git - people/pmueller/ipfire-2.x.git/blob - config/rootfiles/updater/update.sh
Work on update.sh, move core15 to updater
[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 2 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) 2007 IPFire-Team <info@ipfire.org>. #
21 # #
22 ############################################################################
23 #
24 #
25 OLDVERSION="2.1.1"
26 NEWVERSION="2.2-test"
27 CORE="14"
28 KVER="2.6.20.21"
29 ROOT=`grep "root=" /boot/grub/grub.conf | cut -d"=" -f2 | cut -d" " -f1 | tail -n 1`
30 MOUNT=`grep "kernel" /boot/grub/grub.conf | tail -n 1`
31 # Nur den letzten Parameter verwenden
32 echo $MOUNT > /dev/null
33 MOUNT=$_
34 INSTALLEDVERSION=`grep "version = " /opt/pakfire/etc/pakfire.conf | cut -d'"' -f2`
35 INSTALLEDCORE=`cat /opt/pakfire/db/core/mine`
36 OLDKERNEL=`ls /boot/vmlinuz-*-ipfire | cut -d"-" -f2 | tail -n 1`
37 #
38 # check version
39 #
40 if [ ! "$INSTALLEDVERSION" == "$OLDVERSION" ]; then
41 echo Error! This update is only for IPFire $OLDVERSION Core $CORE
42 echo You have installed IPFire $INSTALLEDVERSION Core $INSTALLEDCORE
43 exit 1
44 fi
45 # check core
46 if [ ! "$INSTALLEDCORE" == "$CORE" ]; then
47 echo Error! This update is only for IPFire $OLDVERSION Core $CORE
48 echo You have installed IPFire $INSTALLEDVERSION Core $INSTALLEDCORE
49 exit 2
50 fi
51 #
52 #
53 echo
54 echo Update IPFire $OLDVERSION to $NEWVERSION
55 echo
56 echo Press Enter to begin.
57 read
58 echo
59 #
60 # check if we the backup file already exist
61 if [ -e /var/ipfire/backup/update_$OLDVERSION-$NEWVERSION.tar.bz2 ]; then
62 echo Error! The backupfile of this update already exist!!!
63 echo Have you already installed this update?
64 exit 3
65 fi
66 echo First we made a backup of all files that was inside of the
67 echo update archive. This may take a while ...
68 tar cjvf /var/ipfire/backup/update_$OLDVERSION-$NEWVERSION.tar.bz2 \
69 -T ROOTFILES --exclude='#*' -C / > /dev/null 2>&1
70 echo
71 echo Update IPfire to $NEWVERSON ...
72 #
73 # Backup the old grub config
74 #
75 mv /boot/grub/grub.conf /boot/grub/grub-old.conf
76 #
77 # Unpack the updated files
78 #
79 echo
80 echo Unpack the updated files ...
81 tar xjvf files.ipfire -C /
82 #
83 # Modify grub.conf
84 #
85 echo
86 echo Update grub configuration ...
87 sed -i "s|ROOT|$ROOT|g" /boot/grub/grub.conf
88 sed -i "s|KVER|$KVER|g" /boot/grub/grub.conf
89 sed -i "s|MOUNT|$MOUNT|g" /boot/grub/grub.conf
90 echo "title Old Kernel" >> /boot/grub/grub.conf
91 echo " configfile /grub/grub-old.conf" >> /boot/grub/grub.conf
92 sed -i "s|/vmlinuz-ipfire|/vmlinuz-$OLDKERNEL-ipfire|g" /boot/grub/grub-old.conf
93 #
94 # Made initramdisk
95 #
96 echo
97 echo Create new Initramdisks ...
98 if [ "${ROOT:0:7}" == "/dev/sd" ]; then
99 # Remove ide hook if root is on sda
100 sed -i "s| ide | |g" /etc/mkinitcpio.conf
101 else
102 if [ "${ROOT:0:7}" == "/dev/hd" ]; then
103 # Remove pata hook if root is on hda
104 sed -i "s| pata | |g" /etc/mkinitcpio.conf
105 fi
106 fi
107 mkinitcpio -k $KVER-ipfire -g /boot/ipfirerd-$KVER.img
108 mkinitcpio -k $KVER-ipfire-smp -g /boot/ipfirerd-$KVER-smp.img
109 #
110 # Change version of Pakfire.conf
111 #
112 sed -i "s|$OLDVERSION|$NEWVERSION|g" /opt/pakfire/etc/pakfire.conf
113 #
114 # Create new issue
115 #
116 echo IPFire v$NEWVERSION - www.ipfire.org > /etc/issue
117 echo =================================== >> /etc/issue
118 echo \\n running on \\s \\r \\m >> /etc/issue
119 # Core 15 begin
120 perl -e "require '/var/ipfire/lang.pl'; &Lang::BuildCacheLang"
121 /etc/init.d/mISDN config
122 # Core 15 end
123 echo
124 echo
125 echo Update to IPFire $NEWVERSION finished. Please reboot...
126 echo