forked from vmware-samples/packer-examples-for-vsphere
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconfig.sh
executable file
·38 lines (31 loc) · 848 Bytes
/
config.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#!/usr/bin/env sh
# Copyright 2023 Broadcom. All rights reserved.
# SPDX-License-Identifier: BSD-2
set -e
follow_link() {
FILE="$1"
while [ -h "$FILE" ]; do
# On macOS, readlink -f doesn't work.
FILE="$(readlink "$FILE")"
done
echo "$FILE"
}
SCRIPT_PATH=$(realpath "$(dirname "$(follow_link "$0")")")
CONFIG_PATH=${1:-${SCRIPT_PATH}/config}
mkdir -p "$CONFIG_PATH"
### Copy the example input variables.
echo
echo "> Copying the example input variables..."
cp -av "$SCRIPT_PATH"/builds/*.pkrvars.hcl.example "$CONFIG_PATH"
### Rename the example input variables.
echo
echo "> Renaming the example input variables..."
srcext=".pkrvars.hcl.example"
dstext=".pkrvars.hcl"
for f in "$CONFIG_PATH"/*"${srcext}"; do
bname="${f%"${srcext}"}"
echo "${bname}{${srcext} → ${dstext}}"
mv "${f}" "${bname}${dstext}"
done
echo
echo "> Done."