This repository has been archived by the owner on Jun 6, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathpost.sh
executable file
·84 lines (70 loc) · 2.87 KB
/
post.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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
#!/bin/bash
# SPDX-License-Identifier: Apache-2.0
# Copyright (C) 2019-2021 Intel Corporation
set -o pipefail
# this is provided while using uOS
# shellcheck source=/dev/null
source /opt/bootstrap/functions
PROVISIONER=$1
# shellcheck disable=SC2269 # variable origin: pre.sh
param_bootstrapurl=${param_bootstrapurl}
# shellcheck disable=SC2269 # variable origin: pre.sh
param_token=${param_token}
# shellcheck disable=SC2269 # variable origin: provision_settings
enable_secure_boot=${enable_secure_boot}
# shellcheck disable=SC2269 # variable origin: provision_settings
enable_tpm=${enable_tpm}
# shellcheck disable=SC2269 # variable origin: provision_settings
redfish_ip=${redfish_ip}
# shellcheck disable=SC2269 # variable origin: provision_settings
redfish_user=${redfish_user}
# shellcheck disable=SC2269 # variable origin: provision_settings
redfish_password=${redfish_password}
# shellcheck disable=SC2269 # variable origin: pre.sh
param_parttype=${param_parttype}
# A proxy that has access to out of band management interface
management_proxy="http://${PROVISIONER}:3128/"
redfish_actions=""
if [[ "${enable_secure_boot}" == "true" ]] && [[ $param_parttype == "efi" ]]; then
redfish_actions+=" --sb on"
fi
if [[ "${enable_tpm}" == "true" ]]; then
redfish_actions+=" --tpm on"
fi
if [ -n "${redfish_actions}" ]; then
run "Calling redfish with actions ${redfish_actions}" \
"wget --header \"Authorization: token ${param_token}\" -O - \"${param_bootstrapurl}/redfish.py\" \
| python3 - --ip \"${redfish_ip}\" -u \"${redfish_user}\" -p \"${redfish_password}\" --proxy \"${management_proxy}\" ${redfish_actions}" \
"${PROVISION_LOG}"
fi
stop=$(date +%s)
# shellcheck disable=SC2154 # $start defined in pre.sh
elapsed_total_seconds=$((stop - start))
elapsed_min=$((elapsed_total_seconds / 60))
elapsed_sec=$((elapsed_total_seconds % 60))
run "Finished. Elapsed time: ${elapsed_min} minutes ${elapsed_sec} seconds (total seconds: ${elapsed_total_seconds})" \
"echo 'Finished. Elapsed time: ${elapsed_min} minutes ${elapsed_sec} seconds (total seconds: ${elapsed_total_seconds})'" \
"${PROVISION_LOG}"
run "Provisioning log will be available in /var/log/provisioning.log" \
"true" \
"/dev/null"
cp "${PROVISION_LOG}" "$ROOTFS/var/log/provisioning.log"
# shellcheck disable=SC2154 # $freemem defined in pre.sh
if [ "$freemem" -lt 6291456 ]; then
run "Cleaning up" \
"killall dockerd &&
sleep 3 &&
swapoff $ROOTFS/swap &&
rm $ROOTFS/swap &&
while (! rm -fr $ROOTFS/tmp/ > /dev/null ); do sleep 2; done" \
"${PROVISION_LOG}"
fi
# shellcheck disable=SC2154 # $BOOTFS, $ROOTFS, and $param_diskencrypt defined in pre.sh
umount "$BOOTFS" &&
umount "$ROOTFS" &&
if [[ $param_diskencrypt == 'true' ]]; then
cryptsetup luksClose root 2>&1 | tee -a /dev/console
fi
run "Rebooting in 10 seconds" \
"sleep 10 && reboot" \
"/dev/null"