Skip to content

Commit

Permalink
Use MinIO for DPP binaries
Browse files Browse the repository at this point in the history
Signed-off-by: Pawel Langowski <[email protected]>
  • Loading branch information
PLangowski committed Dec 12, 2024
1 parent c7b8d03 commit d7e9d1a
Show file tree
Hide file tree
Showing 4 changed files with 64 additions and 73 deletions.
2 changes: 1 addition & 1 deletion include/dts-environment.sh
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ DPP_PACKAGES_SCRIPTS_PATH="$DPP_PACKAGE_MANAGER_DIR/packages-scripts"
DPP_SUBMENU_JSON="$DPP_PACKAGES_SCRIPTS_PATH/submenu.json"
DPP_CREDENTIAL_FILE="/etc/cloud-pass"
FW_STORE_URL="${FW_STORE_URL_DEV:-https://dl.3mdeb.com/open-source-firmware/Dasharo}"
FW_STORE_URL_DPP="https://cloud.3mdeb.com/public.php/webdav"
FW_STORE_URL_DPP="dl.dasharo.com"
CLOUD_REQUEST="X-Requested-With: XMLHttpRequest"
BASE_CLOUDSEND_LOGS_URL="39d4biH4SkXD8Zm"
BASE_CLOUDSEND_PASSWORD="1{\[\k6G"
Expand Down
66 changes: 35 additions & 31 deletions include/dts-functions.sh
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,7 @@ board_config() {
PLATFORM_SIGN_KEY="customer-keys/novacustom/novacustom-open-source-firmware-release-1.x-key.asc \
customer-keys/novacustom/dasharo-release-0.9.x-for-novacustom-signing-key.asc"
NEED_SMMSTORE_MIGRATION="true"
BUCKET_DPP="dasharo-novacustom-heads"

case "$SYSTEM_MODEL" in
"NV4XMB,ME,MZ")
Expand Down Expand Up @@ -297,7 +298,7 @@ board_config() {
DASHARO_REL_NAME="novacustom_nv4x_adl"
DASHARO_REL_VER="1.7.2"
HEADS_REL_VER_DPP="0.9.1"
HEADS_LINK_DPP="${FW_STORE_URL_DPP}/${DASHARO_REL_NAME}/v${HEADS_REL_VER_DPP}/${DASHARO_REL_NAME}_v${HEADS_REL_VER_DPP}_heads.rom"
HEADS_LINK_DPP="${DPP_SERVER_USER_ALIAS}/${BUCKET_DPP_HEADS}/${DASHARO_REL_NAME}/v${HEADS_REL_VER_DPP}/${DASHARO_REL_NAME}_v${HEADS_REL_VER_DPP}_heads.rom"
HEADS_SWITCH_FLASHROM_OPT_OVERRIDE="--ifd -i bios"
COMPATIBLE_EC_FW_VERSION="2022-08-31_cbff21b"
if check_if_dasharo; then
Expand Down Expand Up @@ -387,6 +388,8 @@ board_config() {
EC_LINK_COMM="$FW_STORE_URL/$DASHARO_REL_NAME/v$DASHARO_REL_VER/${DASHARO_REL_NAME}_ec_v${DASHARO_REL_VER}.rom"
;;
"Micro-Star International Co., Ltd.")
BUCKET_DPP="dasharo-msi"
BUCKET_DPP_HEADS="dasharo-msi-heads"
case "$SYSTEM_MODEL" in
"MS-7D25")
# Common configuration for all MS-7D25:
Expand Down Expand Up @@ -419,15 +422,15 @@ board_config() {
case "$BOARD_MODEL" in
"PRO Z690-A WIFI DDR4(MS-7D25)" | "PRO Z690-A DDR4(MS-7D25)")
BIOS_LINK_COMM="${FW_STORE_URL}/${DASHARO_REL_NAME}/v${DASHARO_REL_VER}/${DASHARO_REL_NAME}_v${DASHARO_REL_VER}_ddr4.rom"
BIOS_LINK_DPP="${FW_STORE_URL_DPP}/MS-7D25/v${DASHARO_REL_VER_DPP}/${DASHARO_REL_NAME}_v${DASHARO_REL_VER_DPP}_ddr4.rom"
BIOS_LINK_DPP_CAP="${FW_STORE_URL_DPP}/MS-7D25/v${DASHARO_REL_VER_DPP_CAP}/${DASHARO_REL_NAME_CAP}_v${DASHARO_REL_VER_DPP_CAP}_ddr4.cap"
HEADS_LINK_DPP="${FW_STORE_URL_DPP}/MS-7D25/v${HEADS_REL_VER_DPP}/${DASHARO_REL_NAME}_v${HEADS_REL_VER_DPP}_ddr4_heads.rom"
BIOS_LINK_DPP="${BUCKET_DPP}/MS-7D25/v${DASHARO_REL_VER_DPP}/${DASHARO_REL_NAME}_v${DASHARO_REL_VER_DPP}_ddr4.rom"
BIOS_LINK_DPP_CAP="${BUCKET_DPP_HEADS}/MS-7D25/v${DASHARO_REL_VER_DPP_CAP}/${DASHARO_REL_NAME_CAP}_v${DASHARO_REL_VER_DPP_CAP}_ddr4.cap"
HEADS_LINK_DPP="${BUCKET_DPP_HEADS}/MS-7D25/v${HEADS_REL_VER_DPP}/${DASHARO_REL_NAME}_v${HEADS_REL_VER_DPP}_ddr4_heads.rom"
;;
"PRO Z690-A WIFI (MS-7D25)" | "PRO Z690-A (MS-7D25)")
BIOS_LINK_COMM="${FW_STORE_URL}/${DASHARO_REL_NAME}/v${DASHARO_REL_VER}/${DASHARO_REL_NAME}_v${DASHARO_REL_VER}_ddr5.rom"
BIOS_LINK_DPP="${FW_STORE_URL_DPP}/MS-7D25/v${DASHARO_REL_VER_DPP}/${DASHARO_REL_NAME}_v${DASHARO_REL_VER_DPP}_ddr5.rom"
BIOS_LINK_DPP_CAP="${FW_STORE_URL_DPP}/MS-7D25/v${DASHARO_REL_VER_DPP_CAP}/${DASHARO_REL_NAME_CAP}_v${DASHARO_REL_VER_DPP_CAP}_ddr5.cap"
HEADS_LINK_DPP="${FW_STORE_URL_DPP}/MS-7D25/v${HEADS_REL_VER_DPP}/${DASHARO_REL_NAME}_v${HEADS_REL_VER_DPP}_ddr5_heads.rom"
BIOS_LINK_DPP="${BUCKET_DPP}/MS-7D25/v${DASHARO_REL_VER_DPP}/${DASHARO_REL_NAME}_v${DASHARO_REL_VER_DPP}_ddr5.rom"
BIOS_LINK_DPP_CAP="${BUCKET_DPP}/MS-7D25/v${DASHARO_REL_VER_DPP_CAP}/${DASHARO_REL_NAME_CAP}_v${DASHARO_REL_VER_DPP_CAP}_ddr5.cap"
HEADS_LINK_DPP="${BUCKET_DPP_HEADS}/MS-7D25/v${HEADS_REL_VER_DPP}/${DASHARO_REL_NAME}_v${HEADS_REL_VER_DPP}_ddr5_heads.rom"
;;
*)
print_error "Board model $BOARD_MODEL is currently not supported"
Expand Down Expand Up @@ -464,16 +467,16 @@ board_config() {
case "$BOARD_MODEL" in
"PRO Z790-P WIFI DDR4(MS-7E06)" | "PRO Z790-P DDR4(MS-7E06)" | "PRO Z790-P WIFI DDR4 (MS-7E06)" | "PRO Z790-P DDR4 (MS-7E06)")
#BIOS_LINK_COMM="$FW_STORE_URL/$DASHARO_REL_NAME/v$DASHARO_REL_VER/${DASHARO_REL_NAME}_v${DASHARO_REL_VER}_ddr4.rom"
BIOS_LINK_DPP="${FW_STORE_URL_DPP}/MS-7E06/v${DASHARO_REL_VER_DPP}/${DASHARO_REL_NAME}_v${DASHARO_REL_VER_DPP}_ddr4.rom"
BIOS_LINK_DPP_CAP="${FW_STORE_URL_DPP}/MS-7E06/v${DASHARO_REL_VER_DPP_CAP}/${DASHARO_REL_NAME_CAP}_v${DASHARO_REL_VER_DPP_CAP}_ddr4.cap"
HEADS_LINK_DPP="${FW_STORE_URL_DPP}/MS-7E06/v${HEADS_REL_VER_DPP}/${DASHARO_REL_NAME}_v${HEADS_REL_VER_DPP}_ddr4_heads.rom"
BIOS_LINK_DPP="${BUCKET_DPP}/MS-7E06/v${DASHARO_REL_VER_DPP}/${DASHARO_REL_NAME}_v${DASHARO_REL_VER_DPP}_ddr4.rom"
BIOS_LINK_DPP_CAP="${BUCKET_DPP}/MS-7E06/v${DASHARO_REL_VER_DPP_CAP}/${DASHARO_REL_NAME_CAP}_v${DASHARO_REL_VER_DPP_CAP}_ddr4.cap"
HEADS_LINK_DPP="${BUCKET_DPP_HEADS}/MS-7E06/v${HEADS_REL_VER_DPP}/${DASHARO_REL_NAME}_v${HEADS_REL_VER_DPP}_ddr4_heads.rom"
PROGRAMMER_BIOS="internal:boardmismatch=force"
;;
"PRO Z790-P WIFI (MS-7E06)" | "PRO Z790-P (MS-7E06)")
#BIOS_LINK_COMM="$FW_STORE_URL/$DASHARO_REL_NAME/v$DASHARO_REL_VER/${DASHARO_REL_NAME}_v${DASHARO_REL_VER}_ddr5.rom"
BIOS_LINK_DPP="${FW_STORE_URL_DPP}/MS-7E06/v${DASHARO_REL_VER_DPP}/${DASHARO_REL_NAME}_v${DASHARO_REL_VER_DPP}_ddr5.rom"
BIOS_LINK_DPP_CAP="${FW_STORE_URL_DPP}/MS-7E06/v${DASHARO_REL_VER_DPP_CAP}/${DASHARO_REL_NAME_CAP}_v${DASHARO_REL_VER_DPP_CAP}_ddr5.cap"
HEADS_LINK_DPP="${FW_STORE_URL_DPP}/MS-7E06/v${HEADS_REL_VER_DPP}/${DASHARO_REL_NAME}_v${HEADS_REL_VER_DPP}_ddr5_heads.rom"
BIOS_LINK_DPP="${BUCKET_DPP}/MS-7E06/v${DASHARO_REL_VER_DPP}/${DASHARO_REL_NAME}_v${DASHARO_REL_VER_DPP}_ddr5.rom"
BIOS_LINK_DPP_CAP="${BUCKET_DPP}/MS-7E06/v${DASHARO_REL_VER_DPP_CAP}/${DASHARO_REL_NAME_CAP}_v${DASHARO_REL_VER_DPP_CAP}_ddr5.cap"
HEADS_LINK_DPP="${BUCKET_DPP_HEADS}/MS-7E06/v${HEADS_REL_VER_DPP}/${DASHARO_REL_NAME}_v${HEADS_REL_VER_DPP}_ddr5_heads.rom"
;;
*)
print_error "Board model $BOARD_MODEL is currently not supported"
Expand All @@ -489,9 +492,10 @@ board_config() {
;;
"Dell Inc.")
# Common configuration for all Dell releases:
BUCKET_DPP="dasharo-optiplex-uefi"
DASHARO_REL_NAME="dell_optiplex_7010_9010"
DASHARO_REL_VER_DPP="0.1.1"
BIOS_LINK_DPP="$FW_STORE_URL_DPP/v$DASHARO_REL_VER_DPP/${DASHARO_REL_NAME}_v$DASHARO_REL_VER_DPP.rom"
BIOS_LINK_DPP="$BUCKET_DPP/v$DASHARO_REL_VER_DPP/${DASHARO_REL_NAME}_v$DASHARO_REL_VER_DPP.rom"
CAN_INSTALL_BIOS="true"
NEED_SMBIOS_MIGRATION="true"
NEED_BLOB_TRANSMISSION="true"
Expand Down Expand Up @@ -573,6 +577,8 @@ board_config() {
;;
"PC Engines")
# Common configuration for all PC Engines releases:
BUCKET_DPP="dasharo-pcengines"
BUCKET_DPP_SEABIOS="dasharo-pcengines-seabios"
DASHARO_REL_VER_DPP="0.9.0"
CAN_INSTALL_BIOS="true"
DASHARO_REL_VER_DPP_SEABIOS="24.05.00.01"
Expand Down Expand Up @@ -601,8 +607,8 @@ board_config() {
;;
esac

BIOS_LINK_DPP="${FW_STORE_URL_DPP}/pcengines_apu2/v${DASHARO_REL_VER_DPP}/${DASHARO_REL_NAME}_v${DASHARO_REL_VER_DPP}.rom"
BIOS_LINK_DPP_SEABIOS="${FW_STORE_URL_DPP}/pcengines_apu2/v${DASHARO_REL_VER_DPP_SEABIOS}/${DASHARO_REL_NAME}_seabios_v${DASHARO_REL_VER_DPP_SEABIOS}.rom"
BIOS_LINK_DPP="${BUCKET_DPP}/pcengines_apu2/v${DASHARO_REL_VER_DPP}/${DASHARO_REL_NAME}_v${DASHARO_REL_VER_DPP}.rom"
BIOS_LINK_DPP_SEABIOS="${BUCKET_DPP_SEABIOS}/pcengines_apu2/v${DASHARO_REL_VER_DPP_SEABIOS}/${DASHARO_REL_NAME}_seabios_v${DASHARO_REL_VER_DPP_SEABIOS}.rom"

shopt -u nocasematch
;;
Expand All @@ -612,6 +618,7 @@ board_config() {
case "$SYSTEM_MODEL" in
"ODROID-H4")
PLATFORM_SIGN_KEY="dasharo/hardkernel_odroid_h4/dasharo-release-0.x-compatible-with-hardkernel-odroid-h4-family-signing-key.asc"
BUCKET_DPP="dasharo-odroid-h4-plus"
DASHARO_REL_NAME="hardkernel_odroid_h4"
DASHARO_REL_VER_DPP="0.9.0"
;;
Expand All @@ -621,7 +628,7 @@ board_config() {
;;
esac

BIOS_LINK_DPP="$FW_STORE_URL_DPP/$DASHARO_REL_NAME/v$DASHARO_REL_VER_DPP/${DASHARO_REL_NAME}_v$DASHARO_REL_VER_DPP.rom"
BIOS_LINK_DPP="$BUCKET_DPP/$DASHARO_REL_NAME/v$DASHARO_REL_VER_DPP/${DASHARO_REL_NAME}_v$DASHARO_REL_VER_DPP.rom"
;;
"QEMU"|"Emulation")
case "$SYSTEM_MODEL" in
Expand Down Expand Up @@ -748,14 +755,13 @@ download_bios() {
error_check "Cannot access $FW_STORE_URL while downloading signature. Please
check your internet connection"
else
USER_DETAILS="$CLOUDSEND_DOWNLOAD_URL:$CLOUDSEND_PASSWORD"
curl -s -L -f -u "$USER_DETAILS" -H "$CLOUD_REQUEST" "$BIOS_LINK" -o $BIOS_UPDATE_FILE
mc get "${DPP_SERVER_USER_ALIAS}/$BIOS_LINK" "$BIOS_UPDATE_FILE"
error_check "Cannot access $FW_STORE_URL_DPP while downloading binary.
Please check your internet connection and credentials"
curl -s -L -f -u "$USER_DETAILS" -H "$CLOUD_REQUEST" "$BIOS_HASH_LINK" -o $BIOS_HASH_FILE
mc get "${DPP_SERVER_USER_ALIAS}/$BIOS_HASH_LINK" "$BIOS_HASH_FILE"
error_check "Cannot access $FW_STORE_URL_DPP while downloading signature.
Please check your internet connection and credentials"
curl -s -L -f -u "$USER_DETAILS" -H "$CLOUD_REQUEST" "$BIOS_SIGN_LINK" -o $BIOS_SIGN_FILE
mc get "${DPP_SERVER_USER_ALIAS}/$BIOS_SIGN_LINK" "$BIOS_SIGN_FILE"
error_check "Cannot access $FW_STORE_URL_DPP while downloading signature.
Please check your internet connection and credentials"
fi
Expand All @@ -773,6 +779,7 @@ download_ec() {
error_check "Cannot access $FW_STORE_URL while downloading signature. Please
check your internet connection"
else
# TODO: Do we need EC in MinIO?
curl -s -L -f -u "$USER_DETAILS" -H "$CLOUD_REQUEST" "$EC_LINK" -o $EC_UPDATE_FILE
error_check "Cannot access $FW_STORE_URL while downloading binary. Please
check your internet connection and credentials"
Expand Down Expand Up @@ -1302,9 +1309,8 @@ show_dpp_credentials() {
if [ -n "${DPP_IS_LOGGED}" ]; then
echo -e "${BLUE}**${NORMAL} DPP credentials ${NORMAL}"
echo -e "${BLUE}*********************************************************${NORMAL}"
echo -e "${BLUE}**${YELLOW} Logs key: ${NORMAL}${CLOUDSEND_LOGS_URL}"
echo -e "${BLUE}**${YELLOW} Download key: ${NORMAL}${CLOUDSEND_DOWNLOAD_URL}"
echo -e "${BLUE}**${YELLOW} Password: ${NORMAL}${CLOUDSEND_PASSWORD}"
echo -e "${BLUE}**${YELLOW} Email: ${NORMAL}${DPP_EMAIL}"
echo -e "${BLUE}**${YELLOW} Password: ${NORMAL}${DPP_PASSWORD}"
echo -e "${BLUE}*********************************************************${NORMAL}"
fi
}
Expand Down Expand Up @@ -1450,21 +1456,19 @@ main_menu_options(){
"${DPP_KEYS_OPT}")
get_dpp_creds

# Check for Dasharo Firmware for the current platform, continue to
# packages after checking:
check_for_dasharo_firmware

# Try to log in using available DPP credentials, start loop over if login
# was not successful:
login_to_dpp_server
if [ $? -ne 0 ]; then
print_warning "Your credentials do not have access to DPP packages. If you bought one, check the"
print_warning "credentials you have used, and contact support. If you did not buy any DPP"
print_warning "packages - feel free to continue."
print_warning "Your credentials do not have access to DPP packages/firmware. If you bought one, check the"
print_warning "credentials you have used, and contact support."
read -p "Press Enter to continue"
return 0
fi

# Check for Dasharo Firmware for the current platform
check_for_dasharo_firmware

# Check if there is some packages available to install, start loop over if
# no packages is available:
check_avail_dpp_packages || return 0
Expand Down
61 changes: 24 additions & 37 deletions include/dts-subscription.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,17 +19,12 @@ check_for_dasharo_firmware() {
# Ignore "SC2154 (warning): DPP_CREDENTIAL_FILE is referenced but not assigned"
# for external variable:
# shellcheck disable=SC2154
CLOUDSEND_LOGS_URL=$(sed -n '1p' < ${DPP_CREDENTIAL_FILE} | tr -d '\n')
CLOUDSEND_DOWNLOAD_URL=$(sed -n '2p' < ${DPP_CREDENTIAL_FILE} | tr -d '\n')
CLOUDSEND_PASSWORD=$(sed -n '3p' < ${DPP_CREDENTIAL_FILE} | tr -d '\n')
USER_DETAILS="$CLOUDSEND_DOWNLOAD_URL:$CLOUDSEND_PASSWORD"
DPP_EMAIL=$(sed -n '1p' < ${DPP_CREDENTIAL_FILE} | tr -d '\n')
DPP_PASSWORD=$(sed -n '2p' < ${DPP_CREDENTIAL_FILE} | tr -d '\n')

# Check the board information:
board_config

# Create links for logs to be sent to:
TEST_LOGS_URL="https://cloud.3mdeb.com/index.php/s/${CLOUDSEND_LOGS_URL}/authenticate/showShare"

# If board_config function has not set firmware links - exit with warning:
if [ -z "$BIOS_LINK_DPP" ] && [ -z "$HEADS_LINK_DPP" ] && [ -z "$BIOS_LINK_DPP_SEABIOS" ] && [ -z "$BIOS_LINK_DPP_CAP" ]; then
print_warning "There is no Dasharo Firmware available for your platform."
Expand All @@ -39,29 +34,29 @@ check_for_dasharo_firmware() {
# Check for firmware binaries:
if wait_for_network_connection; then
if [ -n "$BIOS_LINK_DPP" ]; then
_check_dwn_req_resp_uefi=$(curl -L -I -s -f -u "$USER_DETAILS" -H "$CLOUD_REQUEST" "$BIOS_LINK_DPP" -o /dev/null -w "%{http_code}")
mc find "${DPP_SERVER_USER_ALIAS}/${BIOS_LINK_DPP}" > /dev/null 2>&1
_check_dwn_req_resp_uefi=$?
fi

if [ -n "$BIOS_LINK_DPP_CAP" ]; then
_check_dwn_req_resp_uefi_cap=$(curl -L -I -s -f -u "$USER_DETAILS" -H "$CLOUD_REQUEST" "$BIOS_LINK_DPP_CAP" -o /dev/null -w "%{http_code}")
mc find "${DPP_SERVER_USER_ALIAS}/${BIOS_LINK_DPP_CAP}" > /dev/null 2>&1
_check_dwn_req_resp_uefi_cap=$?
fi

if [ -n "$HEADS_LINK_DPP" ]; then
_check_dwn_req_resp_heads=$(curl -L -I -s -f -u "$USER_DETAILS" -H "$CLOUD_REQUEST" "$HEADS_LINK_DPP" -o /dev/null -w "%{http_code}")
mc find "${DPP_SERVER_USER_ALIAS}/${HEADS_LINK_DPP}" > /dev/null 2>&1
_check_dwn_req_resp_heads=$?
fi

if [ -n "$BIOS_LINK_DPP_SEABIOS" ]; then
_check_dwn_req_resp_seabios=$(curl -L -I -s -f -u "$USER_DETAILS" -H "$CLOUD_REQUEST" "$BIOS_LINK_DPP_SEABIOS" -o /dev/null -w "%{http_code}")
mc find "${DPP_SERVER_USER_ALIAS}/${BIOS_LINK_DPP_SEABIOS}" > /dev/null 2>&1
_check_dwn_req_resp_seabios=$?
fi

_check_logs_req_resp=$(curl -L -I -s -f -H "$CLOUD_REQUEST" "$TEST_LOGS_URL" -o /dev/null -w "%{http_code}")

# Return 0 if any of Dasharo Firmware binaries is available:
if [ ${_check_dwn_req_resp_uefi} -eq 200 ] || [ ${_check_dwn_req_resp_uefi_cap} -eq 200 ] || [ ${_check_dwn_req_resp_heads} -eq 200 ] || [ ${_check_dwn_req_resp_seabios} -eq 200 ]; then
if [ ${_check_logs_req_resp} -eq 200 ]; then
print_ok "A Dasharo Firmware binary has been found for your platform!"
return 0
fi
if [ ${_check_dwn_req_resp_uefi} -eq 0 ] || [ ${_check_dwn_req_resp_uefi_cap} -eq 0 ] || [ ${_check_dwn_req_resp_heads} -eq 0 ] || [ ${_check_dwn_req_resp_seabios} -eq 0 ]; then
print_ok "A Dasharo Firmware binary has been found for your platform!"
return 0
fi
fi

Expand All @@ -75,26 +70,23 @@ check_for_dasharo_firmware() {

get_dpp_creds() {
echo ""
read -p "Enter logs key: " 'TMP_CLOUDSEND_LOGS_URL'
echo ""
read -p "Enter firmware download key: " 'TMP_CLOUDSEND_DOWNLOAD_URL'
read -p "Enter DPP email: " 'DPP_EMAIL'
echo ""
read -p "Enter password: " 'TMP_CLOUDSEND_PASSWORD'
read -p "Enter password: " 'DPP_PASSWORD'

# Export DPP creds to a file for future use. Currently these are being used
# for both: MinIO (and its mc CLI) and cloudsend (deprecated, all DPP
# sibscribtions will be megrated to MinIO):
echo ${TMP_CLOUDSEND_LOGS_URL} > ${DPP_CREDENTIAL_FILE}
echo ${TMP_CLOUDSEND_DOWNLOAD_URL} >> ${DPP_CREDENTIAL_FILE}
echo ${TMP_CLOUDSEND_PASSWORD} >> ${DPP_CREDENTIAL_FILE}
echo ${DPP_EMAIL} >> ${DPP_CREDENTIAL_FILE}
echo ${DPP_PASSWORD} >> ${DPP_CREDENTIAL_FILE}

print_ok "Dasharo DPP credentials have been saved"
}

login_to_dpp_server(){
# Check if the user is already logged in, log in if not:
if [ -z "$(mc alias list | grep ${CLOUDSEND_DOWNLOAD_URL})" ]; then
if ! mc alias set $DPP_SERVER_USER_ALIAS $DPP_SERVER_ADDRESS $CLOUDSEND_DOWNLOAD_URL $CLOUDSEND_PASSWORD >> $ERR_LOG_FILE 2>&1 ; then
if [ -z "$(mc alias list | grep ${DPP_EMAIL})" ]; then
if ! mc alias set $DPP_SERVER_USER_ALIAS $DPP_SERVER_ADDRESS $DPP_EMAIL $DPP_PASSWORD >> $ERR_LOG_FILE 2>&1 ; then
return 1
fi
fi
Expand All @@ -110,22 +102,17 @@ subscription_routine(){
# Currently it does the following:
# Managing DPP creds., so the loop will detect them;
# Connects to DPP server.
export CLOUDSEND_LOGS_URL
export CLOUDSEND_DOWNLOAD_URL
export CLOUDSEND_PASSWORD
export DPP_EMAIL
export DPP_PASSWORD

# Each time the main menu is rendered, check for DPP credentials and export
# them, if file exists
if [ -e "${DPP_CREDENTIAL_FILE}" ]; then
CLOUDSEND_LOGS_URL=$(sed -n '1p' < ${DPP_CREDENTIAL_FILE} | tr -d '\n')
CLOUDSEND_DOWNLOAD_URL=$(sed -n '2p' < ${DPP_CREDENTIAL_FILE} | tr -d '\n')
CLOUDSEND_PASSWORD=$(sed -n '3p' < ${DPP_CREDENTIAL_FILE} | tr -d '\n')
export USER_DETAILS="$CLOUDSEND_DOWNLOAD_URL:$CLOUDSEND_PASSWORD"
DPP_EMAIL=$(sed -n '1p' < ${DPP_CREDENTIAL_FILE} | tr -d '\n')
DPP_PASSWORD=$(sed -n '2p' < ${DPP_CREDENTIAL_FILE} | tr -d '\n')
export DPP_IS_LOGGED="true"
else
CLOUDSEND_LOGS_URL="$BASE_CLOUDSEND_LOGS_URL"
CLOUDSEND_PASSWORD="$BASE_CLOUDSEND_PASSWORD"
unset CLOUDSEND_DOWNLOAD_URL
unset DPP_EMAIL
unset DPP_IS_LOGGED
return 1
fi
Expand Down
8 changes: 4 additions & 4 deletions scripts/dasharo-deploy
Original file line number Diff line number Diff line change
Expand Up @@ -80,31 +80,31 @@ check_for_firmware_access() {
# This firmware type require user to provide creds:
[ "$DPP_IS_LOGGED" == "true" ] || return 1

curl -sfI -u "$USER_DETAILS" -H "$CLOUD_REQUEST" "$BIOS_LINK_DPP" -o /dev/null
mc find "${DPP_SERVER_USER_ALIAS}/${BIOS_LINK_DPP}" > /dev/null 2>&1

[ $? -ne 0 ] && return 1
;;
dpp_cap)
# This firmware type require user to provide creds:
[ "$DPP_IS_LOGGED" == "true" ] || return 1

curl -sfI -u "$USER_DETAILS" -H "$CLOUD_REQUEST" "$BIOS_LINK_DPP_CAP" -o /dev/null
mc find "${DPP_SERVER_USER_ALIAS}/${BIOS_LINK_DPP_CAP}" > /dev/null 2>&1

[ $? -ne 0 ] && return 1
;;
seabios)
# This firmware type require user to provide creds:
[ "$DPP_IS_LOGGED" == "true" ] || return 1

curl -sfI -u "$USER_DETAILS" -H "$CLOUD_REQUEST" "$BIOS_LINK_DPP_SEABIOS" -o /dev/null
mc find "${DPP_SERVER_USER_ALIAS}/${BIOS_LINK_DPP_SEABIOS}" > /dev/null 2>&1

[ $? -ne 0 ] && return 1
;;
heads)
# This firmware type require user to provide creds:
[ "$DPP_IS_LOGGED" == "true" ] || return 1

curl -sfI -u "$USER_DETAILS" -H "$CLOUD_REQUEST" "$HEADS_LINK_DPP" -o /dev/null
mc find "${DPP_SERVER_USER_ALIAS}/${HEADS_LINK_DPP}" > /dev/null 2>&1

[ $? -ne 0 ] && return 1
;;
Expand Down

0 comments on commit d7e9d1a

Please sign in to comment.