Roger Luethi 6216f40a34 labs: skip osbash scripts in Vagrant
Make Vagrant skip not only osbash commands (lines starting with "cmd "),
but also scripts in the osbash directory. This allows us to use the same
config/scripts.* files for osbash and Vagrant while preventing Vagrant
from executing scripts that are only meant for osbash.

Change-Id: I86d1bb6065a58edcc67015603da59af9d6aff4c7
Implements: blueprint openstack-training-labs
2014-08-20 09:55:57 +02:00

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.nodeinit_vagrant" "scripts.ubuntu" "scripts.$HOSTNAME"; do
echo "Config file $config_file"
vagrant_start_from_config "$config_file"
done