]> git.ipfire.org Git - people/pmueller/ipfire-2.x.git/blob - config/rootfiles/updater/update.sh
updater: add issue and pakfire.conf to backup
[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) 2007 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.20.21"
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 Error! The backupfile of this update already exist!!!
44 echo Have you already installed this update?
45 exit 3
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 issue and packfire conf to backup
50 echo etc/issue >> ROOTFILES
51 echo opt/pakfire/etc/pakfire.conf >> ROOTFILES
52 tar cjvf /var/ipfire/backup/update_$OLDVERSION-$NEWVERSION.tar.bz2 \
53 -T ROOTFILES --exclude='#*' -C / > /dev/null 2>&1
54 echo
55 echo Update IPfire to $NEWVERSON ...
56 #
57 # Backup the old grub config
58 #
59 mv /boot/grub/grub.conf /boot/grub/grub-old.conf
60 #
61 # Unpack the updated files
62 #
63 echo
64 echo Unpack the updated files ...
65 extract_files
66 #
67 # Modify grub.conf
68 #
69 echo
70 echo Update grub configuration ...
71 sed -i "s|ROOT|$ROOT|g" /boot/grub/grub.conf
72 sed -i "s|KVER|$KVER|g" /boot/grub/grub.conf
73 sed -i "s|MOUNT|$MOUNT|g" /boot/grub/grub.conf
74 echo "title Old Kernel" >> /boot/grub/grub.conf
75 echo " configfile /grub/grub-old.conf" >> /boot/grub/grub.conf
76 sed -i "s|/vmlinuz-ipfire|/vmlinuz-$OLDKERNEL-ipfire|g" /boot/grub/grub-old.conf
77 #
78 # Made initramdisk
79 #
80 echo
81 echo Create new Initramdisks ...
82 if [ "${ROOT:0:7}" == "/dev/sd" ]; then
83 # Remove ide hook if root is on sda
84 sed -i "s| ide | |g" /etc/mkinitcpio.conf
85 else
86 if [ "${ROOT:0:7}" == "/dev/hd" ]; then
87 # Remove pata hook if root is on hda
88 sed -i "s| pata | |g" /etc/mkinitcpio.conf
89 fi
90 fi
91 mkinitcpio -k $KVER-ipfire -g /boot/ipfirerd-$KVER.img
92 mkinitcpio -k $KVER-ipfire-smp -g /boot/ipfirerd-$KVER-smp.img
93 #
94 # Change version of Pakfire.conf
95 #
96 sed -i "s|$OLDVERSION|$NEWVERSION|g" /opt/pakfire/etc/pakfire.conf
97 #
98 # Create new issue
99 #
100 echo IPFire v$NEWVERSION - www.ipfire.org > /
101 echo =================================== >> /etc/issue
102 echo \\n running on \\s \\r \\m >> /etc/issue
103 # Core 15 begin
104 perl -e "require '/var/ipfire/lang.pl'; &Lang::BuildCacheLang"
105 /etc/init.d/mISDN config
106 # Core 15 end
107 echo
108 echo
109 echo Update to IPFire $NEWVERSION finished. Please reboot...
110 echo