set version to 2.9 core44
[people/pmueller/ipfire-2.x.git] / src / scripts / backupiso
1 #!/bin/sh
2
3 COREVER=`cat /opt/pakfire/db/core/mine`
4 # FIXME: edit this lines before release
5 URL=http://download.ipfire.org/iso/
6 ISO=ipfire-2.9.i586-full-core$COREVER.iso
7
8 if [ -z "$1" ]; then
9 echo usage: $0 backup-file
10 exit
11 fi
12
13 TS=$1
14
15 mkdir -p /var/tmp/backupiso
16 cd /var/tmp/backupiso
17
18 echo "Fetching ${URL}${ISO}"
19 wget --quiet -c ${URL}${ISO}
20 echo "Fetching ${URL}md5sums.txt"
21 wget --quiet -O ${ISO}.md5 ${URL}${ISO}.md5
22
23 echo "Checking md5 of ${ISO}"
24 md5sum --status -c ${ISO}.md5
25 RETVAR="$?"
26 if [ $RETVAR -eq 0 -o $RETVAR -eq 24 ]
27 then
28 echo "md5 is OK"
29 else
30 echo "md5 mismatch"
31 echo "Fetching again ${URL}${ISO}"
32 wget --quiet -O ${ISO} ${URL}${ISO}
33 fi
34
35 echo "Remastering iso"
36 mkdir -p backupiso.tmp.${TS}
37 mount -o loop ${ISO} backupiso.tmp.${TS}
38 cp -pr backupiso.tmp.${TS} backupiso.${TS}
39 umount backupiso.tmp.${TS}
40 rm -r backupiso.tmp.${TS}
41
42 echo "RESTORE_FILE=${TS}.ipf" >> backupiso.${TS}/boot/unattended.conf
43 cp /var/ipfire/backup/${TS}.ipf backupiso.${TS}
44
45 echo "Running mkisofs"
46 mkisofs -J -r -V "ipfire backup ${TS}" \
47 -b boot/isolinux/isolinux.bin -no-emul-boot -boot-load-size 4 -boot-info-table \
48 -c boot/isolinux/boot.catalog backupiso.${TS} > `basename ${ISO} .iso`-${TS}.iso
49
50 echo "Cleaning up"
51 rm -rf backupiso.${TS}