]> git.ipfire.org Git - people/pmueller/ipfire-2.x.git/blame - src/scripts/backupiso
Early spring clean: Remove trailing whitespaces, and correct licence headers
[people/pmueller/ipfire-2.x.git] / src / scripts / backupiso
CommitLineData
f4459fc9 1#!/bin/sh
66c36198
PM
2###############################################################################
3# #
4# IPFire.org - A linux based firewall #
5# Copyright (C) 2007-2022 IPFire Team <info@ipfire.org> #
6# #
7# This program is free software: you can redistribute it and/or modify #
8# it under the terms of the GNU General Public License as published by #
9# the Free Software Foundation, either version 3 of the License, or #
10# (at your option) any later version. #
11# #
12# This program is distributed in the hope that it will be useful, #
13# but WITHOUT ANY WARRANTY; without even the implied warranty of #
14# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
15# GNU General Public License for more details. #
16# #
17# You should have received a copy of the GNU General Public License #
18# along with this program. If not, see <http://www.gnu.org/licenses/>. #
19# #
20###############################################################################
8a0bc034
MT
21
22# FIXME: edit this lines before release
255273a3 23IPFVER=2.27
6104f2e8 24COREVER=$(cat /opt/pakfire/db/core/mine)
8a0bc034
MT
25
26arch=$(uname -m)
27
492b0b7c
MT
28case "${arch}" in
29 aarch64|x86_64)
30 ;;
8a0bc034 31 *)
492b0b7c 32 echo "Arch is not supported" >&2
8a0bc034
MT
33 exit 1
34 ;;
35esac
36
6104f2e8
AF
37URL="https://downloads.ipfire.org/releases/ipfire-2.x/$IPFVER-core$COREVER/"
38ISO="ipfire-$IPFVER.$arch-full-core$COREVER.iso"
39156085 39
87589bce
MT
40makeiso() {
41 local dir="${1}"
42 local output="${2}"
43
84902aa4 44 local args=
87589bce
MT
45
46 # Add EFI options when EFI image is present
47 if [ -e "${dir}/boot/isolinux/efiboot.img" ]; then
48 args="${args} -eltorito-alt-boot -e boot/isolinux/efiboot.img -no-emul-boot"
49 fi
50
51 # Compose ISO
6104f2e8 52 mkisofs -J -r -V "IPFire ${IPFVER} ${arch}" \
84902aa4
AF
53 -b boot/isolinux/isolinux.bin -no-emul-boot -boot-load-size 4 -boot-info-table \
54 -c boot/isolinux/boot.catalog \
55 ${args} ${dir} > ${output}
87589bce
MT
56
57 # Add DOS paritition table
58 if [ -e "${dir}/boot/isolinux/efiboot.img" ]; then
59 isohybrid --uefi ${output}
60 else
61 isohybrid ${output}
62 fi
63
64 return 0
65}
66
2de6c649 67if [ -z $1 ]; then
f4459fc9
DG
68 echo usage: $0 backup-file
69 exit
70fi
71
72TS=$1
73
74mkdir -p /var/tmp/backupiso
75cd /var/tmp/backupiso
76
39156085 77if [ ! -f ${ISO} ]
3b1dbfba
AF
78then
79 echo "Fetching ${URL}${ISO}"
80 wget --quiet -c ${URL}${ISO}
eb7fff99
AF
81fi
82
2de6c649 83echo "Fetching ${URL}${ISO}.md5"
f6281b9a 84wget --quiet -O ${ISO}.md5 ${URL}${ISO}.md5
f4459fc9
DG
85
86echo "Checking md5 of ${ISO}"
f6281b9a 87md5sum --status -c ${ISO}.md5
39156085 88if [ $? -eq 0 ] || [ $? -eq 24 ]
2de6c649
TE
89then
90 echo "md5 is OK"
91else
92 echo "md5 mismatch"
93 echo "Fetching again ${URL}${ISO}"
94 wget --quiet -O ${ISO} ${URL}${ISO}
95 echo "Checking again md5 of ${ISO}"
96 md5sum --status -c ${ISO}.md5
39156085 97 if [ $? -eq 0 ] || [ $? -eq 24 ]
2de6c649
TE
98 then
99 echo "md5 is OK"
100 else
101 echo "md5 mismatch"
102 echo "aborting backup because md5 mismatch"
103 exit 1
104 fi
f4459fc9 105fi
2de6c649 106rm ${ISO}.md5
f4459fc9
DG
107
108echo "Remastering iso"
109mkdir -p backupiso.tmp.${TS}
110mount -o loop ${ISO} backupiso.tmp.${TS}
111cp -pr backupiso.tmp.${TS} backupiso.${TS}
112umount backupiso.tmp.${TS}
113rm -r backupiso.tmp.${TS}
114
38c6822d
MT
115# Copy backup file to disk
116cp "/var/ipfire/backup/${TS}.ipf" "backupiso.${TS}/backup.ipf"
f4459fc9 117
6104f2e8
AF
118# Add a version tag
119touch "backupiso.${TS}/backup-${TS}.media"
120
f4459fc9 121echo "Running mkisofs"
87589bce 122makeiso backupiso.${TS} $(basename ${ISO} .iso)-${TS}.iso
f4459fc9
DG
123
124echo "Cleaning up"
125rm -rf backupiso.${TS}