From e5bb49333f1ee7a5134bb27dddef1d464f651889 Mon Sep 17 00:00:00 2001 From: Roger Luethi <rl@patchworkscience.org> Date: Tue, 17 Jun 2014 18:07:47 +0200 Subject: [PATCH] Add init_xxx_node.sh This script sets the hostname and configures networking in the node VM. It gets the hostname from its own file name (which is appropriately set by vm_build_node when copying the file). Partial-Bug: 1312764 Implements: blueprint openstack-training-labs Change-Id: I9d0daad40462202c42ddd3a591f93b23d9512d53 --- labs/scripts/osbash/init_xxx_node.sh | 30 ++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 labs/scripts/osbash/init_xxx_node.sh diff --git a/labs/scripts/osbash/init_xxx_node.sh b/labs/scripts/osbash/init_xxx_node.sh new file mode 100644 index 00000000..b77c3207 --- /dev/null +++ b/labs/scripts/osbash/init_xxx_node.sh @@ -0,0 +1,30 @@ +#!/usr/bin/env bash + +# This scripts configures hostname and networking for all nodes. The filename +# determines the node name. + +TOP_DIR=$(cd $(dirname "$0")/.. && pwd) +source "$TOP_DIR/config/paths" +source "$CONFIG_DIR/credentials" +source "$LIB_DIR/functions.guest" + +# Determine hostname from script name +re=".*init_(.*)_node.sh$" +if [[ $0 =~ $re ]]; then + NODE_NAME=${BASH_REMATCH[1]} + NODE_NAME="${NODE_NAME}" +else + echo "ERROR Unable to determine hostname" + exit 1 +fi + +indicate_current_auto + +exec_logfile + +# Set hostname for now and for rebooted system +sudo hostname "$NODE_NAME" >/dev/null +echo "$NODE_NAME" | sudo tee /etc/hostname > /dev/null + +# Configure network interfaces +config_network