[gbc] first version of boardconfig generator
This commit is contained in:
parent
34196cc1f1
commit
3700e12f24
|
@ -0,0 +1,91 @@
|
||||||
|
#!/usr/bin/env bash
|
||||||
|
#
|
||||||
|
# gbc - generate a set of boardconfig files
|
||||||
|
#
|
||||||
|
# Copyright (C) 2011 Bart Van Der Meerssche <bart.vandermeerssche@flukso.net>
|
||||||
|
#
|
||||||
|
# This program is free software: you can redistribute it and/or modify
|
||||||
|
# it under the terms of the GNU General Public License as published by
|
||||||
|
# the Free Software Foundation, either version 3 of the License, or
|
||||||
|
# (at your option) any later version.
|
||||||
|
|
||||||
|
# This program is distributed in the hope that it will be useful,
|
||||||
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
# GNU General Public License for more details.
|
||||||
|
|
||||||
|
# You should have received a copy of the GNU General Public License
|
||||||
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
#
|
||||||
|
|
||||||
|
|
||||||
|
BFLAG=
|
||||||
|
SFLAG=
|
||||||
|
MFLAG=
|
||||||
|
CFALG=
|
||||||
|
|
||||||
|
BATCH="FLxx"
|
||||||
|
SERIAL=1
|
||||||
|
MAC="0123456789abc"
|
||||||
|
COUNT=0
|
||||||
|
|
||||||
|
while getopts 'b:m:s:c:h' OPTION
|
||||||
|
do
|
||||||
|
case $OPTION in
|
||||||
|
b) BFLAG=1
|
||||||
|
BATCH="$OPTARG"
|
||||||
|
;;
|
||||||
|
|
||||||
|
s) SFLAG=1
|
||||||
|
SERIAL="$OPTARG"
|
||||||
|
;;
|
||||||
|
|
||||||
|
m) MFLAG=1
|
||||||
|
MAC="0x$OPTARG"
|
||||||
|
;;
|
||||||
|
|
||||||
|
c) CFLAG=1
|
||||||
|
COUNT="$OPTARG"
|
||||||
|
;;
|
||||||
|
|
||||||
|
h|?) printf "Generate a set of boardconfig (bc) files.\n"
|
||||||
|
printf "Usage: %s -b <batch> [-s <serial>] -m <mac_addr> -c <#bc's> <reference bc>\n" $(basename $0) >&2
|
||||||
|
exit 1
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
done
|
||||||
|
|
||||||
|
shift $(($OPTIND - 1))
|
||||||
|
|
||||||
|
printf "Creating target directory %s.\n" $BATCH
|
||||||
|
mkdir $BATCH
|
||||||
|
|
||||||
|
for ((i = 0; i < COUNT; i++))
|
||||||
|
do
|
||||||
|
FN=$(printf "$BATCH/$BATCH%06d" $((SERIAL + i)))
|
||||||
|
|
||||||
|
printf "Cloning reference file to %s.\n" $FN
|
||||||
|
cp $1 $FN
|
||||||
|
|
||||||
|
ETH=$(echo 16o $((MAC + 2*i)) p | dc)
|
||||||
|
WIFI=$(echo 16o $((MAC + 2*i+1)) p | dc)
|
||||||
|
|
||||||
|
printf "Substituting eth/wifi macs for %s/%s.\n" $ETH $WIFI
|
||||||
|
echo $ETH | xxd -r -p -s $((0x0060)) - $FN
|
||||||
|
echo $WIFI | xxd -r -p -s $((0x0066)) - $FN
|
||||||
|
|
||||||
|
printf "Writing 224 CSPRNG bytes to %s.\n" $FN
|
||||||
|
hexdump -v -e '1/1 "%.2x"' -n 224 /dev/urandom | xxd -r -p -s $((0x1020)) - $FN
|
||||||
|
done
|
||||||
|
|
||||||
|
printf "Writing 32 TRNG bytes to each boardconfig file.\n"
|
||||||
|
printf "Write speed depends on the entropy pool being filled by kernel events.\n"
|
||||||
|
printf "So surf the web, click around, enter keystrokes...\n"
|
||||||
|
|
||||||
|
for ((i = 0; i < COUNT; i++))
|
||||||
|
do
|
||||||
|
FN=$(printf "$BATCH/$BATCH%06d" $((SERIAL + i)))
|
||||||
|
|
||||||
|
printf "Writing 32 TRNG bytes to %s.\n" $FN
|
||||||
|
hexdump -v -e '1/1 "%.2x"' -n 32 /dev/random | xxd -r -p -s $((0x1000)) - $FN
|
||||||
|
done
|
Loading…
Reference in New Issue