
This changeset adds a new init_node command for config/scripts.* and uses it to merge scripts.nodeinit_osbash and scripts.nodeinit_vagrant into the node specific config/scripts.*. This results in some redundancy, but it (hopefully) makes the script configuration easier to follow. It also makes the initial creation and configuration of the VM just another step that can be picked or omitted from script configuration. Implements: blueprint openstack-training-labs Change-Id: Ieadfe2b9540710556100051723e3e6f08855efa3
44 lines
1.2 KiB
Bash
Executable File
44 lines
1.2 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
set -o errexit
|
|
|
|
# Shell provisioning script is renamed and copied to /tmp before being run as
|
|
# root
|
|
TOP_DIR=/vagrant
|
|
source "$TOP_DIR/config/paths"
|
|
source "$LIB_DIR/functions.guest"
|
|
|
|
clean_dir "$LOG_DIR"
|
|
|
|
exec_logpath "$LOG_DIR/$HOSTNAME.log"
|
|
|
|
function vagrant_start_from_config {
|
|
local config_file=$1
|
|
local config_path=$CONFIG_DIR/$config_file
|
|
|
|
if [ ! -f "$config_path" ]; then
|
|
echo >&2 "Config file not found: $config_file"
|
|
return 1
|
|
fi
|
|
|
|
while read -r field_1 field_2; do
|
|
if [[ $field_1 =~ ^# ]]; then
|
|
# Skip lines that are commented out
|
|
continue
|
|
elif [[ "$field_1" = cmd || "$field_1" = osbash ]]; then
|
|
# Skip osbash commands and scripts for Vagrant
|
|
continue
|
|
else
|
|
local dir="$(src_dir_code_to_dir "$field_1")"
|
|
local scr_path=$dir/$field_2
|
|
echo "$scr_path"
|
|
as_root_exec_script "$scr_path"
|
|
fi
|
|
done < "$config_path"
|
|
}
|
|
|
|
# The Vagrantfile uses Ubuntu
|
|
for config_file in "scripts.ubuntu" "scripts.$HOSTNAME"; do
|
|
echo "Config file $config_file"
|
|
vagrant_start_from_config "$config_file"
|
|
done
|