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