From: davidplunkett Date: Fri, 27 Jul 2018 05:41:50 +0000 (-0400) Subject: Allow user to specify the first boot script X-Git-Tag: 0.0.1~10 X-Git-Url: https://gerrit.akraino.org/r/gitweb?a=commitdiff_plain;h=refs%2Fchanges%2F40%2F140%2F1;p=redfish.git Allow user to specify the first boot script Change-Id: I28ef9af9ce8a0950c74d9177ba1b0aa0fbee1195 Signed-off-by: davidplunkett --- diff --git a/firstboot-genesis.sh.template b/firstboot-genesis.sh.template index 8405f2f..e175351 100644 --- a/firstboot-genesis.sh.template +++ b/firstboot-genesis.sh.template @@ -27,23 +27,42 @@ echo " " echo "Updating available packages" apt-get update -apt-get install -y apt-transport-https -echo "Adding docker source and key" -curl -s https://packages.cloud.google.com/apt/doc/apt-key.gpg | apt-key add - -echo "deb http://apt.kubernetes.io/ kubernetes-xenial main" >/etc/apt/sources.list.d/kubernetes.list +echo "Adding IP Tables Rules" +echo 1 > /proc/sys/net/ipv4/ip_forward +iptables -t nat -A POSTROUTING -o bond0.41 -j MASQUERADE +iptables -A FORWARD -i bond0.41 -o eno3 -m state --state RELATED,ESTABLISHED -j ACCEPT +iptables -A FORWARD -i eno3 -o bond0.41 -j ACCEPT -echo "Updating available packages" -apt-get update &>/dev/null +echo "Creating Ceph journal partition and filesystem" +# create ceph journal partition and filesystem + +devices=sdh +size=320 + +echo "creating partions for ceph journal:" +echo $devices -echo "Installing docker" -apt-get install -y docker.io aufs-tools 2>&1 +for d in $devices +do + parted -s /dev/${d} mklabel msdos + parted -s /dev/${d} -- mkpart primary ext4 1 ${size} +done +partprobe +sleep 5 #let udev settle down -echo "Checking that docker is running" -docker ps +devnum=1 +for d in $devices +do + mountpoint=/var/lib/openstack-helm/ceph/journal/ceph${devnum} + mkfs -t ext4 /dev/${d}${devnum} + UUID=$(blkid -o export /dev/${d}${devnum} | sed -ne /^UUID/s/UUID=//p) + mkdir -p ${mountpoint} + echo "UUID=$UUID ${mountpoint} ext4 defaults,nofail 0 0" >>/etc/fstab + devnum=$((devnum+1)) +done -echo "Installing sshpass, python-requests and xorriso" -apt-get install -y sshpass python-requests xorriso 2>&1 +/bin/mount -a exit diff --git a/install_server_os.sh b/install_server_os.sh index 4c2d712..348e22c 100755 --- a/install_server_os.sh +++ b/install_server_os.sh @@ -91,6 +91,7 @@ fi IPXE_VLAN=$SRV_VLAN IPXE_INTF=$SRV_IPXE_INF IPXE_URL=http://$BUILD_WEBIP:$BUILD_WEBPORT/ipxe-$SRV_IPXE_INF-$SRV_VLAN.efi +SRV_FIRSTBOOT_TEMPLATE=${SRV_FIRSTBOOT_TEMPLATE:-firstboot.sh.template} if [ -z "$NO_CONFIRM" ]; then echo "" @@ -170,7 +171,7 @@ fi ## ADD FIRSTBOOT SCRIPT TO WEB ROOT echo "Adding firstboot script [$SRV_NAME.firstboot.sh] to web root [$WEB_ROOT]" -cp -f $TOOLS_ROOT/firstboot.sh.template $WEB_ROOT/$SRV_NAME.firstboot.sh +cp -f $TOOLS_ROOT/$SRV_FIRSTBOOT_TEMPLATE $WEB_ROOT/$SRV_NAME.firstboot.sh for VAR in $(set | grep -P "^SRV_|^BUILD_" | cut -f 1 -d'='); do sed -i -e "s|@@$VAR@@|${!VAR}|g" $WEB_ROOT/$SRV_NAME.firstboot.sh @@ -179,7 +180,7 @@ done ## CHECK THAT ALL VALUES WERE REPLACED MISSING=$(grep -Po "@@.*?@@" $WEB_ROOT/$SRV_NAME.firstboot.sh | sort | uniq) if [ -n "$MISSING" ] ; then - echo "ERROR: Required variable(s) in template [firstboot.sh.template] were not located in the resource file [$RCFILE]" + echo "ERROR: Required variable(s) in template [$SRV_FIRSTBOOT_TEMPLATE] were not located in the resource file [$RCFILE]" echo ${MISSING//@@/} | xargs -n 1 | sed -e 's/^/ /g' exit 1 fi diff --git a/serverrc.template b/serverrc.template index 09114d3..0e54679 100644 --- a/serverrc.template +++ b/serverrc.template @@ -56,6 +56,10 @@ SRV_BIOS_TEMPLATE=dell_r740_g14_uefi_base.xml.template SRV_BOOT_TEMPLATE=dell_r740_g14_uefi_httpboot.xml.template SRV_HTTP_BOOT_DEV=NIC.Slot.3-1-1 +# tempalte to run to configure OS after first boot +# current options are: firstboot.sh.template, firstboot-genesis.sh.tempate or firstboot-airship-iab.sh.template +SRV_FIRSTBOOT_TEMPLATE=firstboot.sh.template + # VLAN to use during build and for final network configuration SRV_VLAN=41