]> git.ipfire.org Git - ipfire-2.x.git/blame - src/scripts/backupiso
Improvement of backup iso script
[ipfire-2.x.git] / src / scripts / backupiso
CommitLineData
f4459fc9 1#!/bin/sh
39156085
JS
2arch=$(uname -m)
3
4case $arch in
5 "i?86")
6 arch="i586"
7 echo "Your arch is $arch"
8 ;;
9 "x86_64")
10 arch="x86_64"
11 echo "Your arch is $arch"
12 ;;
13 *)
14 echo "Arch is not supported"
15 exit 1
16 ;;
17esac
f4459fc9 18
2de6c649 19COREVER=$(cat /opt/pakfire/db/core/mine)
f4459fc9 20# FIXME: edit this lines before release
33513817 21URL="http://download.ipfire.org/releases/ipfire-2.x/2.19-core$COREVER/"
39156085 22ISO="ipfire-2.19.$arch-full-core$COREVER.iso"
f4459fc9 23
2de6c649 24if [ -z $1 ]; then
f4459fc9
DG
25 echo usage: $0 backup-file
26 exit
27fi
28
29TS=$1
30
31mkdir -p /var/tmp/backupiso
32cd /var/tmp/backupiso
33
39156085 34if [ ! -f ${ISO} ]
3b1dbfba
AF
35then
36 echo "Fetching ${URL}${ISO}"
37 wget --quiet -c ${URL}${ISO}
eb7fff99
AF
38fi
39
2de6c649 40echo "Fetching ${URL}${ISO}.md5"
f6281b9a 41wget --quiet -O ${ISO}.md5 ${URL}${ISO}.md5
f4459fc9
DG
42
43echo "Checking md5 of ${ISO}"
f6281b9a 44md5sum --status -c ${ISO}.md5
39156085 45if [ $? -eq 0 ] || [ $? -eq 24 ]
2de6c649
TE
46then
47 echo "md5 is OK"
48else
49 echo "md5 mismatch"
50 echo "Fetching again ${URL}${ISO}"
51 wget --quiet -O ${ISO} ${URL}${ISO}
52 echo "Checking again md5 of ${ISO}"
53 md5sum --status -c ${ISO}.md5
39156085 54 if [ $? -eq 0 ] || [ $? -eq 24 ]
2de6c649
TE
55 then
56 echo "md5 is OK"
57 else
58 echo "md5 mismatch"
59 echo "aborting backup because md5 mismatch"
60 exit 1
61 fi
f4459fc9 62fi
2de6c649 63rm ${ISO}.md5
f4459fc9
DG
64
65echo "Remastering iso"
66mkdir -p backupiso.tmp.${TS}
67mount -o loop ${ISO} backupiso.tmp.${TS}
68cp -pr backupiso.tmp.${TS} backupiso.${TS}
69umount backupiso.tmp.${TS}
70rm -r backupiso.tmp.${TS}
71
38c6822d
MT
72# Copy backup file to disk
73cp "/var/ipfire/backup/${TS}.ipf" "backupiso.${TS}/backup.ipf"
f4459fc9
DG
74
75echo "Running mkisofs"
76mkisofs -J -r -V "ipfire backup ${TS}" \
77 -b boot/isolinux/isolinux.bin -no-emul-boot -boot-load-size 4 -boot-info-table \
2de6c649 78 -c boot/isolinux/boot.catalog backupiso.${TS} > $(basename ${ISO} .iso)-${TS}.iso
aab13a8d 79isohybrid $(basename ${ISO} .iso)-${TS}.iso
f4459fc9
DG
80
81echo "Cleaning up"
82rm -rf backupiso.${TS}