2022-10-11 05:34:57 -04:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
# Copyright (c) Edgeless Systems GmbH
|
|
|
|
#
|
|
|
|
# SPDX-License-Identifier: AGPL-3.0-only
|
|
|
|
|
2022-10-19 07:10:15 -04:00
|
|
|
set -euo pipefail
|
2022-11-10 04:28:35 -05:00
|
|
|
shopt -s inherit_errexit
|
2022-10-19 07:10:15 -04:00
|
|
|
|
2023-02-24 08:25:39 -05:00
|
|
|
# parsing of the command line arguments. check if argv[1] is --debug
|
|
|
|
verbosity=0
|
|
|
|
if [[ $# -gt 0 ]]; then
|
|
|
|
if [[ $1 == "--debug" ]]; then
|
|
|
|
verbosity=-1
|
|
|
|
echo "[Constellation] Debug mode enabled"
|
|
|
|
else
|
|
|
|
echo "[Constellation] Unknown argument: $1"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
else
|
|
|
|
echo "[Constellation] Debug mode disabled"
|
|
|
|
fi
|
|
|
|
|
2022-10-19 07:10:15 -04:00
|
|
|
# Prepare the encrypted volume by either initializing it with a random key or by aquiring the key from another bootstrapper.
|
|
|
|
# Store encryption key (random or recovered key) in /run/cryptsetup-keys.d/state.key
|
2023-02-24 08:25:39 -05:00
|
|
|
disk-mapper \
|
|
|
|
-csp "${CONSTEL_CSP}" \
|
|
|
|
-v "${verbosity}"
|
|
|
|
|
2022-10-19 07:10:15 -04:00
|
|
|
if [[ $? -ne 0 ]]; then
|
2022-11-10 08:17:04 -05:00
|
|
|
echo "Failed to prepare state disk"
|
|
|
|
sleep 2 # give the serial console time to print the error message
|
|
|
|
exit $? # exit with the same error code as disk-mapper
|
2022-10-19 07:10:15 -04:00
|
|
|
fi
|