-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcreate-media.sh
executable file
·44 lines (37 loc) · 965 Bytes
/
create-media.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#!/bin/bash
#if [ ! "`whoami`" = root ]; then
# echo "require root" 1>&2
# exit 1
#fi
FTP_SERVERS=(ftp.jaist.ac.jp ftp.tsukuba.wide.ad.jp)
MAIL="[email protected]"
IMAGE="arch.iso"
LOOPDIR=$(mktemp -d)
if [ ! -s "$IMAGE" ]; then
for FTP_SERVER in "$FTP_SERVERS"; do
FNAME=$(ftp -n <<EOT | sed -ne '/\.iso$/p' | sed -e 's/^.* \([^ ]*\)$/\1/'
open $FTP_SERVER
user anonymous $MAIL
cd /pub/Linux/ArchLinux/iso/latest
ls
close
EOT
)
curl "ftp://$FTP_SERVER/pub/Linux/ArchLinux/iso/latest/$FNAME" -o "$IMAGE"
if [ -s "$IMAGE" ]; then
MD5SUM=$(curl "ftp://$FTP_SERVER/pub/Linux/ArchLinux/iso/latest/md5sums.txt" | sed -ne "/$FNAME/p" | awk '{print $1}')
MD5SUM2=$(md5sum "$IMAGE" | awk '{print $1}')
if [ "$MD5SUM" = "$MD5SUM2" ]; then
break
fi
fi
rm -f "$IMAGE"
done
fi
if [ ! -s "$IMAGE" ]; then
echo "image download error" 1>&2
exit 1
fi
#mount -o loop "$IMAGE" "$LOOPDIR"
#cp -r setup-scripts "$LOOPDIR/root"
#umount "$LOOPDIR"