1 |
#!/usr/bin/env bash |
2 |
# PXE Boot Update |
3 |
# |
4 |
# Douglas Thrift |
5 |
# |
6 |
# $Id$ |
7 |
|
8 |
set -e |
9 |
shopt -s extglob nullglob |
10 |
|
11 |
tftpboot=/tftpboot |
12 |
root=$(realpath `dirname $0`) |
13 |
|
14 |
cd $root |
15 |
|
16 |
if [[ $# -ne 0 ]]; then |
17 |
systems=($@) |
18 |
else |
19 |
echo "Usage: `basename $0` [distribution...]" |
20 |
exit 1 |
21 |
fi |
22 |
|
23 |
function directory() |
24 |
{ |
25 |
directory="$tftpboot/$system${1:+/$1}" |
26 |
|
27 |
mkdir -p $directory |
28 |
cd $directory |
29 |
} |
30 |
|
31 |
function get() |
32 |
{ |
33 |
wget -cT 10 $@ |
34 |
|
35 |
for file in ${@##*/}; do |
36 |
case $file in |
37 |
(*.zip) |
38 |
unzip -o $file |
39 |
rm $file |
40 |
;; |
41 |
(*.@(iso|tar.@(bz2|gz))) |
42 |
bsdtar xvf $file |
43 |
rm $file |
44 |
;; |
45 |
esac |
46 |
done |
47 |
|
48 |
chmod -R u+w . |
49 |
} |
50 |
|
51 |
function debian() |
52 |
{ |
53 |
for architecture in ${architectures[*]}; do |
54 |
directory $architecture |
55 |
get $mirror/dists/$distribution/main/installer-$architecture/current/images/netboot/netboot.tar.gz |
56 |
done |
57 |
} |
58 |
|
59 |
function hexify() |
60 |
{ |
61 |
for byte in ${1//./ }; do |
62 |
printf %02X $byte |
63 |
done |
64 |
|
65 |
echo |
66 |
} |
67 |
|
68 |
for system in ${systems[*]}; do |
69 |
source $root/$system |
70 |
done |