update to Debian 12 (2)
[debian6500.git] / master / opt / cluster / bin / create_flash_disk.sh
1 #!/bin/sh
2
3 VERSION=1.1
4
5 IMAGE=flash.imz
6 DISK=flash
7
8 while [ $# -gt 0 ]; do
9 case "$1" in
10 -b) shift; bios="$1";;
11 -h) echo "usage: $(basename $0) [-b bios.rom] [-h] [-i ipmi.rom] [-v]"; exit 0;;
12 -i) shift; ipmi="$1";;
13 -v) echo "$(basename $0) version $VERSION"; exit 0;;
14 *) echo "unknown argument '$1'"; exit 1;;
15 esac
16 shift
17 done
18
19 [ -n "$bios" ] && { [ -f "$bios" ] && NAME="bios" || { echo "bios rom not found '$bios'"; exit 1; }; }
20 [ -n "$ipmi" ] && { [ -f "$ipmi" ] && NAME="ipmi" || { echo "ipmi rom not found '$ipmi'"; exit 1; }; }
21 [ "$bios" -a "$ipmi" ] && NAME="bios-ipmi"
22 [ "$NAME" ] || { echo "no rom specified"; exit 1; }
23 [ $(id -u) -eq 0 ] || { echo "must be root"; exit 1; }
24 [ -f $IMAGE ] || { echo "can't find $IMAGE, must be in /opt/tftp"; exit 1; }
25
26 gunzip -d < $IMAGE > $DISK.img
27
28 [ -d $DISK ] || mkdir $DISK
29
30 mount $DISK.img $DISK -o loop,offset=32256
31
32 [ -f "$bios" ] && cp $bios $DISK/bios.bin
33 [ -f "$ipmi" ] && cp $ipmi $DISK/ipmi.bin
34 sync
35
36 umount $DISK
37
38 gzip -c < $DISK.img > $DISK-$NAME.imz
39 rm -f $DISK.img
40 rmdir $DISK