feat: add support for copying vars files for individual builds
This commit is contained in:
27
config.sh
27
config.sh
@@ -7,24 +7,31 @@ source common.sh
|
|||||||
SCRIPT_PATH=$(realpath "$(dirname "$(follow_link "$0")")")
|
SCRIPT_PATH=$(realpath "$(dirname "$(follow_link "$0")")")
|
||||||
CONFIG_PATH=${1:-${SCRIPT_PATH}/config}
|
CONFIG_PATH=${1:-${SCRIPT_PATH}/config}
|
||||||
|
|
||||||
mkdir -p "$CONFIG_PATH"
|
# Define the script and config paths
|
||||||
|
follow_link_result=$(follow_link "$0")
|
||||||
|
if ! SCRIPT_PATH=$(realpath "$(dirname "${follow_link_result}")"); then
|
||||||
|
echo "Error: follow_link or realpath failed"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
CONFIG_PATH=${1:-${SCRIPT_PATH}/config}
|
||||||
|
|
||||||
|
mkdir -p "${CONFIG_PATH}"
|
||||||
### Copy the example input variables.
|
### Copy the example input variables.
|
||||||
echo
|
echo
|
||||||
echo "> Copying the example input variables..."
|
echo "> Copying the example input variables..."
|
||||||
cp -av "$SCRIPT_PATH"/builds/*.pkrvars.hcl.example "$CONFIG_PATH"
|
cp -av "${SCRIPT_PATH}"/builds/*.pkrvars.hcl.example "${CONFIG_PATH}"
|
||||||
|
find "${SCRIPT_PATH}"/builds/*/ -type f -name "*.pkrvars.hcl.example" | while IFS= read -r srcfile; do
|
||||||
|
srcdir=$(dirname "${srcfile}" | tr -s /)
|
||||||
|
dstfile=$(echo "${srcdir#"${SCRIPT_PATH}"/builds/}" | tr '/' '-')
|
||||||
|
cp -av "${srcfile}" "${CONFIG_PATH}/${dstfile}.pkrvars.hcl.example"
|
||||||
|
done
|
||||||
|
|
||||||
### Rename the example input variables.
|
### Rename the example input variables.
|
||||||
echo
|
echo
|
||||||
echo "> Renaming the example input variables..."
|
echo "> Renaming the example input variables..."
|
||||||
srcext=".pkrvars.hcl.example"
|
for file in "${CONFIG_PATH}"/*.pkrvars.hcl.example; do
|
||||||
dstext=".pkrvars.hcl"
|
mv -- "${file}" "${file%.example}"
|
||||||
|
|
||||||
for f in "$CONFIG_PATH"/*"${srcext}"; do
|
|
||||||
bname="${f%"${srcext}"}"
|
|
||||||
echo "${bname}{${srcext} → ${dstext}}"
|
|
||||||
mv "${f}" "${bname}${dstext}"
|
|
||||||
done
|
done
|
||||||
|
|
||||||
echo
|
echo
|
||||||
echo "> Done."
|
echo "> Done."
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user