[v2] Improvement of backup iso script
Message ID | 1483370228-1118-1-git-send-email-jonatan.schlag@ipfire.org |
---|---|
State | Accepted |
Commit | 391560854f64ad2385adb3ff25dbbcec0ff92668 |
Headers |
Return-Path: <development-bounces@lists.ipfire.org> Received: from mail01.ipfire.org (unknown [172.28.1.200]) by web02.ipfire.org (Postfix) with ESMTP id 41F8962084 for <patchwork@ipfire.org>; Mon, 2 Jan 2017 16:17:13 +0100 (CET) Received: from mail01.ipfire.org (localhost [IPv6:::1]) by mail01.ipfire.org (Postfix) with ESMTP id 818D6B8A; Mon, 2 Jan 2017 16:17:12 +0100 (CET) Received: from fangorn.local.familyschlag (dslb-088-073-210-219.088.073.pools.vodafone-ip.de [88.73.210.219]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-SHA256 (128/128 bits)) (No client certificate requested) by mail01.ipfire.org (Postfix) with ESMTPSA id 6EB7792E; Mon, 2 Jan 2017 16:17:10 +0100 (CET) From: Jonatan Schlag <jonatan.schlag@ipfire.org> To: development@lists.ipfire.org Subject: [PATCH v2] Improvement of backup iso script Date: Mon, 2 Jan 2017 16:17:08 +0100 Message-Id: <1483370228-1118-1-git-send-email-jonatan.schlag@ipfire.org> X-Mailer: git-send-email 2.1.4 X-BeenThere: development@lists.ipfire.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: IPFire development talk <development.lists.ipfire.org> List-Unsubscribe: <http://lists.ipfire.org/mailman/options/development>, <mailto:development-request@lists.ipfire.org?subject=unsubscribe> List-Archive: <http://lists.ipfire.org/pipermail/development/> List-Post: <mailto:development@lists.ipfire.org> List-Help: <mailto:development-request@lists.ipfire.org?subject=help> List-Subscribe: <http://lists.ipfire.org/mailman/listinfo/development>, <mailto:development-request@lists.ipfire.org?subject=subscribe> Errors-To: development-bounces@lists.ipfire.org Sender: "Development" <development-bounces@lists.ipfire.org> |
Message
Jonatan Schlag
Jan. 3, 2017, 2:17 a.m. UTC
The backup iso script did not check the arch of the host. On x86_64 host
the wrong iso was downloaded.
Furthermore, there were some if clauses which could cause trouble which
I also tried to improve.
(For example: -e is valid if we have a directory or a file, but we want
to check for a file only )
Fixes: 11258
Signed-off-by: Jonatan Schlag <jonatan.schlag@ipfire.org>
---
src/scripts/backupiso | 24 ++++++++++++++++++++----
1 file changed, 20 insertions(+), 4 deletions(-)
Comments
Thank you very much for your fixes. Merged. -Michael On Mon, 2017-01-02 at 16:17 +0100, Jonatan Schlag wrote: > The backup iso script did not check the arch of the host. On x86_64 host > the wrong iso was downloaded. > > Furthermore, there were some if clauses which could cause trouble which > I also tried to improve. > (For example: -e is valid if we have a directory or a file, but we want > to check for a file only ) > > Fixes: 11258 > > Signed-off-by: Jonatan Schlag <jonatan.schlag@ipfire.org> > --- > src/scripts/backupiso | 24 ++++++++++++++++++++---- > 1 file changed, 20 insertions(+), 4 deletions(-) > > diff --git a/src/scripts/backupiso b/src/scripts/backupiso > index 014e8e9..1a682d0 100644 > --- a/src/scripts/backupiso > +++ b/src/scripts/backupiso > @@ -1,9 +1,25 @@ > #!/bin/sh > +arch=$(uname -m) > + > +case $arch in > + "i?86") > + arch="i586" > + echo "Your arch is $arch" > + ;; > + "x86_64") > + arch="x86_64" > + echo "Your arch is $arch" > + ;; > + *) > + echo "Arch is not supported" > + exit 1 > + ;; > +esac > > COREVER=$(cat /opt/pakfire/db/core/mine) > # FIXME: edit this lines before release > URL="http://download.ipfire.org/releases/ipfire-2.x/2.19-core$COREVER/" > -ISO="ipfire-2.19.i586-full-core$COREVER.iso" > +ISO="ipfire-2.19.$arch-full-core$COREVER.iso" > > if [ -z $1 ]; then > echo usage: $0 backup-file > @@ -15,7 +31,7 @@ TS=$1 > mkdir -p /var/tmp/backupiso > cd /var/tmp/backupiso > > -if [ ! -e ${ISO} ] > +if [ ! -f ${ISO} ] > then > echo "Fetching ${URL}${ISO}" > wget --quiet -c ${URL}${ISO} > @@ -26,7 +42,7 @@ wget --quiet -O ${ISO}.md5 ${URL}${ISO}.md5 > > echo "Checking md5 of ${ISO}" > md5sum --status -c ${ISO}.md5 > -if [ $? -eq 0 -o $? -eq 24 ] > +if [ $? -eq 0 ] || [ $? -eq 24 ] > then > echo "md5 is OK" > else > @@ -35,7 +51,7 @@ else > wget --quiet -O ${ISO} ${URL}${ISO} > echo "Checking again md5 of ${ISO}" > md5sum --status -c ${ISO}.md5 > - if [ $? -eq 0 -o $? -eq 24 ] > + if [ $? -eq 0 ] || [ $? -eq 24 ] > then > echo "md5 is OK" > else
Hi, Tested. But it won't download anything. The scripts creates the IPF-file and stops. Old script creates the IPF-file: "Backup von 20170102-2039.ipf" Downloads the correct ISO: "Backup von ipfire-2.19.i586-full-core108.iso" ...and works as usual: "Backup von ipfire-2.19.i586-full-core108-20170102-2039.iso" For today, I haven't got the time to look any further - will try again tomorrow. Perhaps something wrong with... ..." case $arch in "i?86") ..." "uname -m" says => "i686" Best, Matthias On 02.01.2017 20:17, Michael Tremer wrote: > Thank you very much for your fixes. Merged. > > -Michael > > On Mon, 2017-01-02 at 16:17 +0100, Jonatan Schlag wrote: >> The backup iso script did not check the arch of the host. On x86_64 host >> the wrong iso was downloaded. >> >> Furthermore, there were some if clauses which could cause trouble which >> I also tried to improve. >> (For example: -e is valid if we have a directory or a file, but we want >> to check for a file only ) >> >> Fixes: 11258 >> >> Signed-off-by: Jonatan Schlag <jonatan.schlag@ipfire.org> >> --- >> src/scripts/backupiso | 24 ++++++++++++++++++++---- >> 1 file changed, 20 insertions(+), 4 deletions(-) >> >> diff --git a/src/scripts/backupiso b/src/scripts/backupiso >> index 014e8e9..1a682d0 100644 >> --- a/src/scripts/backupiso >> +++ b/src/scripts/backupiso >> @@ -1,9 +1,25 @@ >> #!/bin/sh >> +arch=$(uname -m) >> + >> +case $arch in >> + "i?86") >> + arch="i586" >> + echo "Your arch is $arch" >> + ;; >> + "x86_64") >> + arch="x86_64" >> + echo "Your arch is $arch" >> + ;; >> + *) >> + echo "Arch is not supported" >> + exit 1 >> + ;; >> +esac >> >> COREVER=$(cat /opt/pakfire/db/core/mine) >> # FIXME: edit this lines before release >> URL="http://download.ipfire.org/releases/ipfire-2.x/2.19-core$COREVER/" >> -ISO="ipfire-2.19.i586-full-core$COREVER.iso" >> +ISO="ipfire-2.19.$arch-full-core$COREVER.iso" >> >> if [ -z $1 ]; then >> echo usage: $0 backup-file >> @@ -15,7 +31,7 @@ TS=$1 >> mkdir -p /var/tmp/backupiso >> cd /var/tmp/backupiso >> >> -if [ ! -e ${ISO} ] >> +if [ ! -f ${ISO} ] >> then >> echo "Fetching ${URL}${ISO}" >> wget --quiet -c ${URL}${ISO} >> @@ -26,7 +42,7 @@ wget --quiet -O ${ISO}.md5 ${URL}${ISO}.md5 >> >> echo "Checking md5 of ${ISO}" >> md5sum --status -c ${ISO}.md5 >> -if [ $? -eq 0 -o $? -eq 24 ] >> +if [ $? -eq 0 ] || [ $? -eq 24 ] >> then >> echo "md5 is OK" >> else >> @@ -35,7 +51,7 @@ else >> wget --quiet -O ${ISO} ${URL}${ISO} >> echo "Checking again md5 of ${ISO}" >> md5sum --status -c ${ISO}.md5 >> - if [ $? -eq 0 -o $? -eq 24 ] >> + if [ $? -eq 0 ] || [ $? -eq 24 ] >> then >> echo "md5 is OK" >> else >
Am Mo, 2. Jan, 2017 um 8:53 schrieb Matthias Fischer <matthias.fischer@ipfire.org>: > Hi, > > Tested. But it won't download anything. The scripts creates the > IPF-file > and stops. > > Old script creates the IPF-file: > > "Backup von 20170102-2039.ipf" > > Downloads the correct ISO: > > "Backup von ipfire-2.19.i586-full-core108.iso" > > ...and works as usual: > > "Backup von ipfire-2.19.i586-full-core108-20170102-2039.iso" > > For today, I haven't got the time to look any further - will try again > tomorrow. Perhaps something wrong with... > > ..." > case $arch in > "i?86") > ..." Just remove all "" in the case statement "i?86" => i?68 and it should work. I will send a patch later today. > > "uname -m" says => "i686" > > Best, > Matthias > > On 02.01.2017 20:17, Michael Tremer wrote: >> Thank you very much for your fixes. Merged. >> >> -Michael >> >> On Mon, 2017-01-02 at 16:17 +0100, Jonatan Schlag wrote: >>> The backup iso script did not check the arch of the host. On >>> x86_64 host >>> the wrong iso was downloaded. >>> >>> Furthermore, there were some if clauses which could cause trouble >>> which >>> I also tried to improve. >>> (For example: -e is valid if we have a directory or a file, but we >>> want >>> to check for a file only ) >>> >>> Fixes: 11258 >>> >>> Signed-off-by: Jonatan Schlag <jonatan.schlag@ipfire.org> >>> --- >>> src/scripts/backupiso | 24 ++++++++++++++++++++---- >>> 1 file changed, 20 insertions(+), 4 deletions(-) >>> >>> diff --git a/src/scripts/backupiso b/src/scripts/backupiso >>> index 014e8e9..1a682d0 100644 >>> --- a/src/scripts/backupiso >>> +++ b/src/scripts/backupiso >>> @@ -1,9 +1,25 @@ >>> #!/bin/sh >>> +arch=$(uname -m) >>> + >>> +case $arch in >>> + "i?86") >>> + arch="i586" >>> + echo "Your arch is $arch" >>> + ;; >>> + "x86_64") >>> + arch="x86_64" >>> + echo "Your arch is $arch" >>> + ;; >>> + *) >>> + echo "Arch is not supported" >>> + exit 1 >>> + ;; >>> +esac >>> >>> COREVER=$(cat /opt/pakfire/db/core/mine) >>> # FIXME: edit this lines before release >>> >>> URL="http://download.ipfire.org/releases/ipfire-2.x/2.19-core$COREVER/" >>> -ISO="ipfire-2.19.i586-full-core$COREVER.iso" >>> +ISO="ipfire-2.19.$arch-full-core$COREVER.iso" >>> >>> if [ -z $1 ]; then >>> echo usage: $0 backup-file >>> @@ -15,7 +31,7 @@ TS=$1 >>> mkdir -p /var/tmp/backupiso >>> cd /var/tmp/backupiso >>> >>> -if [ ! -e ${ISO} ] >>> +if [ ! -f ${ISO} ] >>> then >>> echo "Fetching ${URL}${ISO}" >>> wget --quiet -c ${URL}${ISO} >>> @@ -26,7 +42,7 @@ wget --quiet -O ${ISO}.md5 ${URL}${ISO}.md5 >>> >>> echo "Checking md5 of ${ISO}" >>> md5sum --status -c ${ISO}.md5 >>> -if [ $? -eq 0 -o $? -eq 24 ] >>> +if [ $? -eq 0 ] || [ $? -eq 24 ] >>> then >>> echo "md5 is OK" >>> else >>> @@ -35,7 +51,7 @@ else >>> wget --quiet -O ${ISO} ${URL}${ISO} >>> echo "Checking again md5 of ${ISO}" >>> md5sum --status -c ${ISO}.md5 >>> - if [ $? -eq 0 -o $? -eq 24 ] >>> + if [ $? -eq 0 ] || [ $? -eq 24 ] >>> then >>> echo "md5 is OK" >>> else >> Jonatan