Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions config.sh
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,13 @@ jq -n \
--arg fs_test_image "${IMAGES_PATH}/fs_test_image.qcow2" \
--arg iso_path "${ISO_PATH}" \
--arg workspace_path "${WORKSPACE_PATH}" \
--arg windows_password "${WINDOWS_PASSWORD}" \
'{
"config.json": {
"config.json": ({
"iso_path": $iso_path,
"extra_software": $extra_software,
"workspace_path": $workspace_path,
},
"workspace_path": $workspace_path
} + if $windows_password != "" then {"windows_password": $windows_password} else {} end),
"lib/engines/hckinstall/hckinstall.json": {
"hck_setup_scripts_path": $hlk_setup_scripts,
},
Expand Down
31 changes: 17 additions & 14 deletions helpers.sh
Original file line number Diff line number Diff line change
Expand Up @@ -27,23 +27,26 @@ command_exists() {
}

from_env_or_read() {
env_name="${1}"
read_msg="${2}"
local env_name="${1}"
local read_msg="${2}"
local value
local default_value="${!env_name}"

if [ -z "${!env_name}" ]; then
read -r -p "${read_msg}: " value
echo "${value}"
else
if [ "${INSTALL_SILENT}" == "true" ]; then
echo "${!env_name}"
if [ "${INSTALL_SILENT}" == "true" ]; then
echo "${default_value}"
return
fi

if [ -n "${default_value}" ]; then
read -r -p "${read_msg} [${default_value}]: " value
if [ -z "${value}" ]; then
echo "${default_value}"
else
read -r -p "${read_msg} [${!env_name}]: " value
if [ -z "${value}" ]; then
echo "${!env_name}"
else
echo "${value}"
fi
echo "${value}"
fi
else
read -r -p "${read_msg}: " value
echo "${value}"
fi
}

Expand Down
2 changes: 2 additions & 0 deletions install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -43,12 +43,14 @@ repos_dir="$(from_env_or_read "REPOS_DIR" "Please provide path to repos director
iso_path="$(from_env_or_read "ISO_PATH" "Please provide path to ISO directory")"
images_path="$(from_env_or_read "IMAGES_PATH" "Please provide path to images directory")"
workspace_path="$(from_env_or_read "WORKSPACE_PATH" "Please provide path to workspace directory")"
windows_password="$(from_env_or_read "WINDOWS_PASSWORD" "Please provide HLK windows password (or press Enter to use default)")"

echo "REPOS_DIR='${repos_dir}'" > "${bootstrap}"
echo >>"${bootstrap}"
echo "ISO_PATH='${iso_path}'" >>"${bootstrap}"
echo "IMAGES_PATH='${images_path}'" >>"${bootstrap}"
echo "WORKSPACE_PATH='${workspace_path}'" >>"${bootstrap}"
echo "WINDOWS_PASSWORD='${windows_password}'" >>"${bootstrap}"
echo >>"${bootstrap}"
echo >>"${bootstrap}"

Expand Down