-
Notifications
You must be signed in to change notification settings - Fork 5
/
proxmox_oraclelinux_89.sh
executable file
·47 lines (36 loc) · 1.09 KB
/
proxmox_oraclelinux_89.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
39
40
41
42
43
44
45
46
47
#!/usr/bin/env bash
# Start time
start_time=$(date +%s%N)
export PACKER_LOG=0
if [ -e secrets/proxmox.sh ]; then
# shellcheck source=secrets/proxmox.sh
source secrets/proxmox.sh
else
echo "secrets/proxmox.sh not found"
fi
version="oraclelinux89"
family="rhel"
var_file="proxmox/variables_proxmox_${version}.pkvars.hcl"
template="proxmox/proxmox_${family}.pkr.hcl"
packer validate --var-file="$var_file" "$template"
rc=$?
if [ $rc -ne 0 ]; then
echo "Packer validate failed - exiting now"
exit $rc
else
packer build --force --var-file="$var_file" "$template"
rc=$?
fi
if [ $rc -ne 0 ]; then
echo "Packer build failed - exiting now"
exit $rc
fi
# End time
end_time=$(date +%s%N)
# Calculate time difference in seconds
time_diff_seconds=$(( (end_time - start_time) / 1000000000 ))
# Convert time difference to hours, minutes, and seconds
hours=$(( time_diff_seconds / 3600 ))
minutes=$(( (time_diff_seconds % 3600) / 60 ))
seconds=$(( time_diff_seconds % 60 ))
echo "Packer build took: $hours hours, $minutes minutes, and $seconds seconds."