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