Land an extension of baremetal-mkinitrd.sh which can also build flavours, with a start at making hwdiscovery and hwburning flavours
This commit is contained in:
parent
5cc195e391
commit
7da463e617
@ -22,6 +22,36 @@ EOF
|
||||
exit 1
|
||||
fi
|
||||
|
||||
FLAVOUR=${FLAVOUR:-baremetal}
|
||||
echo "Building flavour(s): ${FLAVOUR}"
|
||||
|
||||
if [[ "$FLAVOUR" == *hwdiscovery* ]] ; then
|
||||
HWDISCOVERY_BINARIES="lshw"
|
||||
for binary in ${HWDISCOVERY_BINARIES} ; do
|
||||
LOCATION=$(which $binary)
|
||||
if [ -z "$LOCATION" ]; then
|
||||
echo "$binary is not found in PATH" 1>&2
|
||||
echo "Please install it"
|
||||
exit 1
|
||||
fi
|
||||
done
|
||||
FLAVOUR_BINARIES="${FLAVOUR_BINARIES} ${HWDISCOVERY_BINARIES}"
|
||||
fi
|
||||
|
||||
if [[ "$FLAVOUR" == *hwburnin* ]] ; then
|
||||
HWDISCOVERY_BINARIES="spew memtester"
|
||||
for binary in ${HWDISCOVERY_BINARIES} ; do
|
||||
LOCATION=$(which $binary)
|
||||
if [ -z "$LOCATION" ]; then
|
||||
echo "$binary is not found in PATH" 1>&2
|
||||
echo "Please install it"
|
||||
exit 1
|
||||
fi
|
||||
done
|
||||
FLAVOUR_BINARIES="${FLAVOUR_BINARIES} ${HWDISCOVERY_BINARIES}"
|
||||
fi
|
||||
|
||||
|
||||
BUSYBOX=${BUSYBOX:-$(which busybox)}
|
||||
if [ -z "$BUSYBOX" ]; then
|
||||
echo "busybox is not found in PATH" 1>&2
|
||||
@ -85,7 +115,7 @@ udev_log="no"
|
||||
EOF
|
||||
|
||||
libs=
|
||||
for i in "$BUSYBOX" bash modprobe udevd udevadm wget tgtd tgtadm reboot shutdown; do
|
||||
for i in "$BUSYBOX" bash modprobe udevd udevadm wget tgtd tgtadm reboot shutdown $FLAVOUR_BINARIES; do
|
||||
if "$BUSYBOX" --list | grep "^$i\$" >/dev/null; then
|
||||
continue
|
||||
fi
|
||||
|
@ -33,6 +33,16 @@ function get_kernel_parameter() {
|
||||
return 1
|
||||
}
|
||||
|
||||
function string_contains() {
|
||||
local string=$1
|
||||
local word=$2
|
||||
if [ "$string" != "${string/$word/}" ]; then
|
||||
return 0
|
||||
else
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
function load_modules_by_udev() {
|
||||
depmod
|
||||
udevadm trigger --action=add
|
||||
|
55
scripts/init
55
scripts/init
@ -34,6 +34,8 @@ mount -t proc proc /proc
|
||||
|
||||
readonly _BOOTIF_=$(get_kernel_parameter BOOTIF)
|
||||
readonly _IP_=$(get_kernel_parameter ip)
|
||||
readonly _CMDLINE_FLAVOUR=$(get_kernel_parameter FLAVOUR)
|
||||
readonly FLAVOUR=${_CMDLINE_FLAVOUR:-baremetal}
|
||||
readonly BOOT_MAC_ADDRESS=$(echo "$_BOOTIF_" | sed -e "s/-/:/g" | sed -e "s/^01://g" | tr 'a-f' 'A-F')
|
||||
readonly BOOT_IP_ADDRESS=$(echo "$_IP_" | cut -d':' -f1)
|
||||
readonly BOOT_SERVER=$(echo "$_IP_" | cut -d':' -f2)
|
||||
@ -45,7 +47,8 @@ readonly DEPLOYMENT_ID=$(get_kernel_parameter deployment_id)
|
||||
readonly DEPLOYMENT_KEY=$(get_kernel_parameter deployment_key)
|
||||
readonly ISCSI_TARGET_IQN=$(get_kernel_parameter iscsi_target_iqn)
|
||||
|
||||
if [ -z "$ISCSI_TARGET_IQN" ]; then
|
||||
string_contains $FLAVOUR "baremetal"
|
||||
if [ "$?" == "0" -a -z "$ISCSI_TARGET_IQN" ]; then
|
||||
echo "iscsi_target_iqn is not defined"
|
||||
echo "Starting troubleshooting shell."
|
||||
bash
|
||||
@ -129,25 +132,43 @@ done
|
||||
|
||||
echo "network ready"
|
||||
|
||||
target_disk=`find_disk "$DISK"`
|
||||
echo "start iSCSI target on $target_disk"
|
||||
start_iscsi_target "$ISCSI_TARGET_IQN" "$target_disk" ALL
|
||||
if [ $? -ne 0 ]; then
|
||||
echo "Could not find disk to use."
|
||||
echo "Starting troubleshooting shell."
|
||||
bash
|
||||
string_contains $FLAVOUR "baremetal"
|
||||
if [ "$?" == "0" ]; then
|
||||
target_disk=`find_disk "$DISK"`
|
||||
echo "start iSCSI target on $target_disk"
|
||||
start_iscsi_target "$ISCSI_TARGET_IQN" "$target_disk" ALL
|
||||
if [ $? -ne 0 ]; then
|
||||
echo "Could not find disk to use."
|
||||
echo "Starting troubleshooting shell."
|
||||
bash
|
||||
fi
|
||||
|
||||
echo "request boot server to deploy image"
|
||||
d="i=$DEPLOYMENT_ID&k=$DEPLOYMENT_KEY&a=$BOOT_IP_ADDRESS&n=$ISCSI_TARGET_IQN"
|
||||
wget --post-data "$d" "http://$BOOT_SERVER:10000"
|
||||
|
||||
echo "waiting for notice of complete"
|
||||
nc -l -p 10000
|
||||
|
||||
echo "stop iSCSI target on $target_disk"
|
||||
|
||||
stop_iscsi_target
|
||||
fi
|
||||
|
||||
echo "request boot server to deploy image"
|
||||
d="i=$DEPLOYMENT_ID&k=$DEPLOYMENT_KEY&a=$BOOT_IP_ADDRESS&n=$ISCSI_TARGET_IQN"
|
||||
wget --post-data "$d" "http://$BOOT_SERVER:10000"
|
||||
string_contains $FLAVOUR "hwdiscovery"
|
||||
if [ "$?" == "0" ]; then
|
||||
echo "Starting HW Discovery"
|
||||
# XXX: Collect iLO specific data, bundle everything up and POST it somewhere
|
||||
lshw -json # XXX: Do something with this
|
||||
sleep 30
|
||||
fi
|
||||
|
||||
echo "waiting for notice of complete"
|
||||
nc -l -p 10000
|
||||
|
||||
echo "stop iSCSI target on $target_disk"
|
||||
|
||||
stop_iscsi_target
|
||||
string_contains $FLAVOUR "hwburnin"
|
||||
if [ "$?" == "0" ]; then
|
||||
echo "Starting HW Burnin"
|
||||
memtester 1G 10 # XXX: Discover RAM size
|
||||
# XXX: Discover and test disks with spew
|
||||
fi
|
||||
|
||||
echo "rebooting"
|
||||
reboot -f
|
||||
|
Loading…
Reference in New Issue
Block a user