]> git.ipfire.org Git - ipfire-2.x.git/blob - src/scripts/backupiso
Merge branch 'next' of ssh://git.ipfire.org/pub/git/ipfire-2.x into next
[ipfire-2.x.git] / src / scripts / backupiso
1 #!/bin/sh
2 arch=$(uname -m)
3
4 case $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 ;;
17 esac
18
19 COREVER=$(cat /opt/pakfire/db/core/mine)
20 # FIXME: edit this lines before release
21 URL="http://download.ipfire.org/releases/ipfire-2.x/2.19-core$COREVER/"
22 ISO="ipfire-2.19.$arch-full-core$COREVER.iso"
23
24 if [ -z $1 ]; then
25 echo usage: $0 backup-file
26 exit
27 fi
28
29 TS=$1
30
31 mkdir -p /var/tmp/backupiso
32 cd /var/tmp/backupiso
33
34 if [ ! -f ${ISO} ]
35 then
36 echo "Fetching ${URL}${ISO}"
37 wget --quiet -c ${URL}${ISO}
38 fi
39
40 echo "Fetching ${URL}${ISO}.md5"
41 wget --quiet -O ${ISO}.md5 ${URL}${ISO}.md5
42
43 echo "Checking md5 of ${ISO}"
44 md5sum --status -c ${ISO}.md5
45 if [ $? -eq 0 ] || [ $? -eq 24 ]
46 then
47 echo "md5 is OK"
48 else
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
54 if [ $? -eq 0 ] || [ $? -eq 24 ]
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
62 fi
63 rm ${ISO}.md5
64
65 echo "Remastering iso"
66 mkdir -p backupiso.tmp.${TS}
67 mount -o loop ${ISO} backupiso.tmp.${TS}
68 cp -pr backupiso.tmp.${TS} backupiso.${TS}
69 umount backupiso.tmp.${TS}
70 rm -r backupiso.tmp.${TS}
71
72 # Copy backup file to disk
73 cp "/var/ipfire/backup/${TS}.ipf" "backupiso.${TS}/backup.ipf"
74
75 echo "Running mkisofs"
76 mkisofs -J -r -V "ipfire backup ${TS}" \
77 -b boot/isolinux/isolinux.bin -no-emul-boot -boot-load-size 4 -boot-info-table \
78 -c boot/isolinux/boot.catalog backupiso.${TS} > $(basename ${ISO} .iso)-${TS}.iso
79 isohybrid $(basename ${ISO} .iso)-${TS}.iso
80
81 echo "Cleaning up"
82 rm -rf backupiso.${TS}