Skip to content

Commit b8389c7

Browse files
committed
CI: add -x for debugging to install-windows-updates script
1 parent 6b673a1 commit b8389c7

File tree

1 file changed

+18
-18
lines changed
  • ci/tasks/install-windows-updates

1 file changed

+18
-18
lines changed
Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,23 @@
11
#!/bin/bash
2-
3-
set -eu
2+
set -eu -o pipefail
3+
set -x
44

55
SCRIPT_DIR="$( cd "$( dirname "$0" )" && pwd )"
66

7-
source ${SCRIPT_DIR}/../../common-scripts/update_nimbus_urls_and_cert.sh
7+
source "${SCRIPT_DIR}/../../common-scripts/update_nimbus_urls_and_cert.sh"
88

99
cat > ca.crt <<END_OF_CERT
1010
$VCENTER_CA_CERT
1111
END_OF_CERT
1212
export GOVC_TLS_CA_CERTS=ca.crt
1313

1414
vm_ipath=${STEMBUILD_CONSTRUCT_TARGET_VM}
15-
vm_username=${VM_USERNAME}
16-
vm_password=${VM_PASSWORD}
15+
vm_username="${VM_USERNAME}"
16+
vm_password="${VM_PASSWORD}"
1717

1818
powershell_exe="\\Windows\\System32\\WindowsPowerShell\\V1.0\\powershell.exe"
1919

20-
govc_pwsh_cmd="govc guest.start -vm.ipath=${vm_ipath} -l=${vm_username}:${vm_password} $powershell_exe"
20+
govc_pwsh_cmd="govc guest.start -vm.ipath=${vm_ipath} -l=${vm_username}:${vm_password} ${powershell_exe}"
2121

2222
# get wu-install /wu-update set up to work on the vm...
2323

@@ -37,9 +37,9 @@ function run_pwsh_command_with_govc() {
3737
command=$1
3838
echo "Running $command"
3939
pid=$(
40-
$govc_pwsh_cmd ${command}
40+
${govc_pwsh_cmd} "${command}"
4141
)
42-
return=$(govc guest.ps -vm.ipath="${vm_ipath}" -l="${vm_username}:${vm_password}" -p=${pid} -X -json | jq '.processInfo[0].exitCode')
42+
return=$(govc guest.ps -vm.ipath="${vm_ipath}" -l="${vm_username}:${vm_password}" -p="${pid}" -X -json | jq '.processInfo[0].exitCode')
4343
echo "${command} returned ${return}"
4444
}
4545

@@ -50,22 +50,22 @@ run_pwsh_command_with_govc 'Install-Module -Name PSWindowsUpdate -MinimumVersion
5050

5151
returnWindowsUpdateCount="exit (([array](Get-WindowsUpdate)).Count)"
5252
echo "getting update count"
53-
get_update_count_pid=$($govc_pwsh_cmd ${returnWindowsUpdateCount})
53+
get_update_count_pid=$(${govc_pwsh_cmd} "${returnWindowsUpdateCount}")
5454
echo "getting update count exit code via guest.ps"
55-
updates_remaining=$(govc guest.ps -vm.ipath="${vm_ipath}" -l="${vm_username}:${vm_password}" -p=${get_update_count_pid} -X -json | jq '.processInfo[0].exitCode')
55+
updates_remaining=$(govc guest.ps -vm.ipath="${vm_ipath}" -l="${vm_username}:${vm_password}" -p="${get_update_count_pid}" -X -json | jq '.processInfo[0].exitCode')
56+
5657
echo "Windows Updates to install: $updates_remaining"
5758
while [[ updates_remaining -ne 0 ]]; do
58-
5959
install_update_pid=$(
60-
$govc_pwsh_cmd Install-WindowsUpdate -AcceptAll -AutoReboot
60+
${govc_pwsh_cmd} Install-WindowsUpdate -AcceptAll -AutoReboot
6161
)
6262
echo "install-WU pid is $install_update_pid"
6363

6464

6565
# ignore unreachable agent if the vm just went down for reboot
6666
# -X blocks until the guest process exits
6767
set +e
68-
govc guest.ps -vm.ipath="${vm_ipath}" -l="${vm_username}:${vm_password}" -p=${install_update_pid} -X
68+
govc guest.ps -vm.ipath="${vm_ipath}" -l="${vm_username}:${vm_password}" -p="${install_update_pid}" -X
6969
set -e
7070
echo "Install-WU done"
7171

@@ -76,19 +76,19 @@ while [[ updates_remaining -ne 0 ]]; do
7676

7777
echo "VM reachable"
7878
updates_remaining=
79-
while [[ -z "$updates_remaining" ]] ; do
79+
while [[ -z "${updates_remaining}" ]] ; do
8080
echo "Trying to discover how many updates remain..."
8181
# ignore failures here since the vmware tools agent may be down while updates are being applied
8282
set +e
83-
get_update_count_pid=$($govc_pwsh_cmd ${returnWindowsUpdateCount})
84-
updates_remaining=$(govc guest.ps -vm.ipath="${vm_ipath}" -l="${vm_username}:${vm_password}" -p=${get_update_count_pid} -X -json | jq '.ProcessInfo[0].ExitCode')
83+
get_update_count_pid=$(${govc_pwsh_cmd} "${returnWindowsUpdateCount}")
84+
updates_remaining=$(govc guest.ps -vm.ipath="${vm_ipath}" -l="${vm_username}:${vm_password}" -p="${get_update_count_pid}" -X -json | jq '.ProcessInfo[0].ExitCode')
8585
set -e
8686
done
87-
echo "Updates remaining: $updates_remaining"
87+
echo "Updates remaining: ${updates_remaining}"
8888
done
8989

9090
run_pwsh_command_with_govc "Get-Hotfix > C:\\hotfix.log"
9191

92-
govc guest.download -l ${vm_username}:${vm_password} -vm=${vm_ipath} "C:\\hotfix.log" hotfix-log/hotfixes.log
92+
govc guest.download -l "${vm_username}:${vm_password}" -vm="${vm_ipath}" "C:\\hotfix.log" hotfix-log/hotfixes.log
9393

9494
run_pwsh_command_with_govc "Dism.exe /online /Cleanup-Image /StartComponentCleanup"

0 commit comments

Comments
 (0)