]>
Commit | Line | Data |
---|---|---|
f4459fc9 | 1 | #!/bin/sh |
39156085 JS |
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 | |
f4459fc9 | 18 | |
2de6c649 | 19 | COREVER=$(cat /opt/pakfire/db/core/mine) |
f4459fc9 | 20 | # FIXME: edit this lines before release |
33513817 | 21 | URL="http://download.ipfire.org/releases/ipfire-2.x/2.19-core$COREVER/" |
39156085 | 22 | ISO="ipfire-2.19.$arch-full-core$COREVER.iso" |
f4459fc9 | 23 | |
2de6c649 | 24 | if [ -z $1 ]; then |
f4459fc9 DG |
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 | ||
39156085 | 34 | if [ ! -f ${ISO} ] |
3b1dbfba AF |
35 | then |
36 | echo "Fetching ${URL}${ISO}" | |
37 | wget --quiet -c ${URL}${ISO} | |
eb7fff99 AF |
38 | fi |
39 | ||
2de6c649 | 40 | echo "Fetching ${URL}${ISO}.md5" |
f6281b9a | 41 | wget --quiet -O ${ISO}.md5 ${URL}${ISO}.md5 |
f4459fc9 DG |
42 | |
43 | echo "Checking md5 of ${ISO}" | |
f6281b9a | 44 | md5sum --status -c ${ISO}.md5 |
39156085 | 45 | if [ $? -eq 0 ] || [ $? -eq 24 ] |
2de6c649 TE |
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 | |
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 | 62 | fi |
2de6c649 | 63 | rm ${ISO}.md5 |
f4459fc9 DG |
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 | ||
38c6822d MT |
72 | # Copy backup file to disk |
73 | cp "/var/ipfire/backup/${TS}.ipf" "backupiso.${TS}/backup.ipf" | |
f4459fc9 DG |
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 \ | |
2de6c649 | 78 | -c boot/isolinux/boot.catalog backupiso.${TS} > $(basename ${ISO} .iso)-${TS}.iso |
aab13a8d | 79 | isohybrid $(basename ${ISO} .iso)-${TS}.iso |
f4459fc9 DG |
80 | |
81 | echo "Cleaning up" | |
82 | rm -rf backupiso.${TS} |