From 1b76499fcc824b00af9c9e004cfeb1745b30d9f1 Mon Sep 17 00:00:00 2001 From: davidplunkett Date: Tue, 21 Aug 2018 06:25:30 +0000 Subject: [PATCH] fixed timeouts, dependancy checks, dhcp conf, etc Change-Id: Ibc7c99efc69f1bd27c2f211840bf8b22ef185b91 Signed-off-by: davidplunkett --- apply_dellxml.sh | 13 ++++++++----- install_server_os.sh | 23 +++++++++++++++-------- serverrc.template | 8 ++------ setup_tools.sh | 16 +++++++++++----- update_webroot.sh | 2 +- 5 files changed, 37 insertions(+), 25 deletions(-) diff --git a/apply_dellxml.sh b/apply_dellxml.sh index e881af0..a9ac87c 100755 --- a/apply_dellxml.sh +++ b/apply_dellxml.sh @@ -74,11 +74,14 @@ if [ -n "$RCFILE" ] && [ -f "$RCFILE" ]; then fi # CHECK A FEW REQUIRED VARIABLES - BUT NOT ALL -if [ -z "$SRV_NAME" ] || [ -z "$SRV_OOB_IP" ] || [ -z "$SRV_OOB_USR" ] || [ -z "$SRV_OOB_PWD" ]; then - echo "ERROR: Invalid or missing variables in rcfile [$RCFILE]" - echo "usage: ./apply_dellxml.sh [--rc settingsfile] --template templatefile [--no-confirm] [--no-apply-hw] [--help]" - exit 1 -fi +CHECKLIST="SRV_NAME SRV_OOB_IP SRV_OOB_USR SRV_OOB_PWD BUILD_WEBIP BUILD_WEBPORT" +for VAR in $CHECKLIST; do + if [ -z "${!VAR}" ] ; then + echo "ERROR: Invalid or missing variable [$VAR] = [${!VAR}] in rcfile [$RCFILE]" + echo "usage: ./apply_dellxml.sh [--rc settingsfile] --template templatefile [--no-confirm] [--no-apply-hw] [--help]" + exit 1 + fi +done # CHECK IF TEMPLATE PASSED AND EXISTS if [ -z "$TEMPLATE" ] || ! [ -f "$TOOLS_ROOT/$TEMPLATE" ]; then diff --git a/install_server_os.sh b/install_server_os.sh index 157a0c8..e23ccbe 100755 --- a/install_server_os.sh +++ b/install_server_os.sh @@ -244,9 +244,16 @@ subnet $SRV_SUBNET netmask $SRV_NETMASK { } EOF +## CHECK THAT SRV_BLD_SCRIPT EXISTS +if [ ! -f "$WEB_ROOT/$SRV_BLD_SCRIPT" ]; then + echo "ERROR: Missing SRV_BLD_SCRIPT [$SRV_BLD_SCRIPT] from web root [$WEB_ROOT]" + exit 1 +fi + echo "Updating dhcp configuration [$DHCP_ROOT/dhcpd.conf] with server [$SRV_NAME]" -## DELETE ANY HOST ENTRY WITH THE SAME MAC ADDRESS (IGNORING THE NAME WHICH COULD CHANGE) +## DELETE ANY HOST ENTRY WITH THE SAME MAC ADDRESS OR NAME perl -i -p0e "s/^host.*?$SRV_MAC.*?\n\}\n//gms" $DHCP_ROOT/dhcpd.conf +perl -i -p0e "s/^host *$SRV_NAME *{.*?\n\}\n//gms" $DHCP_ROOT/dhcpd.conf cat >>$DHCP_ROOT/dhcpd.conf < /dev/null -docker rm akraino-dhcp &> /dev/null -docker run -dit --name akraino-dhcp --rm --net=host -v "$DHCP_ROOT":/data networkboot/dhcpd $BUILD_INTERFACE +docker restart akraino-dhcp &> /dev/null ## DONE ENDTIME=$(date +%s) diff --git a/serverrc.template b/serverrc.template index 0e54679..2b36042 100644 --- a/serverrc.template +++ b/serverrc.template @@ -17,10 +17,6 @@ # export https_proxy=http://your.proxy.com:8080/ # -# Set the ip and port to use when creating the web server -BUILD_WEBIP=192.168.2.5 -BUILD_WEBPORT=8090 - # host name for server SRV_NAME=aknode44 @@ -48,8 +44,8 @@ SRV_BLD_INF=enp94s0f0 SRV_BOOT_DEVICE=sda # ipxe script to use - based on the os version and kernel to install -# valid options are script-hwe-16.04.4-amd64.ipxe or script-16.04.4-amd64.ipxe -SRV_BLD_SCRIPT=script-hwe-16.04.4-amd64.ipxe +# valid options are script-hwe-16.04.5-amd64.ipxe or script-16.04.5-amd64.ipxe +SRV_BLD_SCRIPT=script-hwe-16.04.5-amd64.ipxe # template xml file to set bios and raid configuration settings SRV_BIOS_TEMPLATE=dell_r740_g14_uefi_base.xml.template diff --git a/setup_tools.sh b/setup_tools.sh index 3356de7..d8619d3 100755 --- a/setup_tools.sh +++ b/setup_tools.sh @@ -63,11 +63,17 @@ mkdir -p $WEB_ROOT mkdir -p $DHCP_ROOT mkdir -p $BUILD_ROOT -## CHECK XORRISO INSTALLED -if ! dpkg -l | grep xorriso >>/dev/null; then - echo "FAILED: required package xorriso not found. try sudo 'apt-get install xorriso -y'" - exit 1 -fi +## CHECK THAT REQUIRED PACKAGES ARE INSTALLED +PACKAGES="xorriso sshpass python-requests coreutils" +for PKG in $PACKAGES ; do + if ! dpkg -l | grep $PKG >>/dev/null; then + echo "Attempting to install missing package $PKG" + if ! apt-get install -y $PKG; then + echo "FAILED: required package $PKG not found. try sudo 'apt-get install $PKG -y'" + exit 1 + fi + fi +done ## DOWNLOAD TOOLS TO TOOLS_ROOT IF TOOLS FOLDER MISSING if [ ! -d "$TOOLS_ROOT" ]; then diff --git a/update_webroot.sh b/update_webroot.sh index ba6ad29..c02147d 100755 --- a/update_webroot.sh +++ b/update_webroot.sh @@ -75,7 +75,7 @@ if [ -z $UBUNTU_ISO ] || ! xorriso --indev $UBUNTU_ISO --check-media &>/dev/null echo "WARNING: ISO file [$UBUNTU_ISO] appears to be missing or corrupt. Downloading instead." xorriso --indev $UBUNTU_ISO --check-media 2>&1 | sed -e "s/^/ /g" export UBUNTU_ISO=${UBUNTU_URL##*/} - echo "WARNING: Attempting to us [$UBUNTU_ISO] instead." + echo "WARNING: Attempting to use [$UBUNTU_ISO] instead." if ! [ -f $WEB_ROOT/$UBUNTU_ISO ]; then echo "Downloading Ubuntu iso from [$UBUNTU_URL] to [$UBUNTU_ISO]" curl -Lo $WEB_ROOT/$UBUNTU_ISO $UBUNTU_URL -- 2.16.6