Skip to content

Local Novacustom update #82

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 4 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions include/dts-environment.sh
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ RESIGNED_BIOS_UPDATE_FILE="/tmp/biosupdate_resigned.rom"
SYSTEM_UUID_FILE="/tmp/system_uuid.txt"
SERIAL_NUMBER_FILE="/tmp/serial_number.txt"

LOCAL_FW_BINARIES="/etc/dasharo-nc"
# dasharo-deploy backup cmd related variables, do we still use and need this as
# backup is placed in HCL?
ROOT_DIR="/"
Expand Down
128 changes: 12 additions & 116 deletions include/dts-functions.sh
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,6 @@ fum_exit() {
if [ "$FUM" == "fum" ]; then
print_error "Update cannot be performed"
print_warning "Starting bash session"
send_dts_logs ask
/bin/bash
fi
}
Expand Down Expand Up @@ -228,7 +227,7 @@ board_config() {
# We download firmwares via network. At this point, the network connection
# must be up already.

wait_for_network_connection
# wait_for_network_connection

echo "Checking if board is Dasharo compatible."
case "$SYSTEM_VENDOR" in
Expand All @@ -241,7 +240,7 @@ board_config() {
customer-keys/novacustom/dasharo-release-0.9.x-for-novacustom-signing-key.asc"
NEED_SMMSTORE_MIGRATION="true"
BUCKET_DPP_HEADS="dasharo-novacustom-heads"

PROGRAMMER_BIOS="internal:boardmismatch=force"
case "$SYSTEM_MODEL" in
"NV4XMB,ME,MZ")
DASHARO_REL_NAME="novacustom_nv4x_tgl"
Expand Down Expand Up @@ -345,6 +344,7 @@ board_config() {
case $BOARD_MODEL in
"V540TU")
DASHARO_REL_NAME="novacustom_v54x_mtl"
EC_NAME="novacustom_v540tu_ec"
FLASHROM_ADD_OPT_UPDATE_OVERRIDE="--ifd -i bios"
HAVE_HEADS_FW="true"
HEADS_REL_VER_DPP="0.9.0"
Expand All @@ -353,6 +353,7 @@ board_config() {
;;
"V560TU")
DASHARO_REL_NAME="novacustom_v56x_mtl"
EC_NAME="novacustom_v560tu_ec"
FLASHROM_ADD_OPT_UPDATE_OVERRIDE="--ifd -i bios"
HAVE_HEADS_FW="true"
HEADS_REL_VER_DPP="0.9.0"
Expand Down Expand Up @@ -1387,11 +1388,6 @@ show_main_menu() {
if [ "${SYSTEM_VENDOR}" != "QEMU" ] && [ "${SYSTEM_VENDOR}" != "Emulation" ]; then
echo -e "${BLUE}**${YELLOW} ${REST_FIRM_OPT})${BLUE} Restore firmware from Dasharo HCL report${NORMAL}"
fi
if [ -n "${DPP_IS_LOGGED}" ]; then
echo -e "${BLUE}**${YELLOW} ${DPP_KEYS_OPT})${BLUE} Edit your DPP keys${NORMAL}"
else
echo -e "${BLUE}**${YELLOW} ${DPP_KEYS_OPT})${BLUE} Load your DPP keys${NORMAL}"
fi
if [ -f "${DPP_SUBMENU_JSON}" ]; then
echo -e "${BLUE}**${YELLOW} ${DPP_SUBMENU_OPT})${BLUE} DTS extensions${NORMAL}"
fi
Expand All @@ -1404,25 +1400,14 @@ main_menu_options() {
case ${OPTION} in
"${HCL_REPORT_OPT}")
print_disclaimer
read -p "Do you want to support Dasharo development by sending us logs with your hardware configuration? [N/y] "
case ${REPLY} in
yes | y | Y | Yes | YES)
export SEND_LOGS="true"
echo "Thank you for contributing to the Dasharo development!"
;;
*)
export SEND_LOGS="false"
echo "Logs will be saved in root directory."
echo "Please consider supporting Dasharo by sending the logs next time."
;;
esac
export SEND_LOGS="false"
if [ "${SEND_LOGS}" == "true" ]; then
# DEPLOY_REPORT variable is used in dasharo-hcl-report to determine
# which logs should be printed in the terminal, in the future whole
# dts scripting should get some LOGLEVEL and maybe dumping working
# logs to file
export DEPLOY_REPORT="false"
wait_for_network_connection && ${CMD_DASHARO_HCL_REPORT} && LOGS_SENT="1"
wait_for_network_connection && ${CMD_DASHARO_HCL_REPORT}
else
export DEPLOY_REPORT="false"
${CMD_DASHARO_HCL_REPORT}
Expand All @@ -1437,26 +1422,10 @@ main_menu_options() {
# TODO: this could be handled in a better way:
[ "${SYSTEM_VENDOR}" = "QEMU" ] || [ "${SYSTEM_VENDOR}" = "Emulation" ] && return 0

if wait_for_network_connection; then
echo "Preparing ..."
if [ -z "${LOGS_SENT}" ]; then
export SEND_LOGS="true"
export DEPLOY_REPORT="true"
if ! ${CMD_DASHARO_HCL_REPORT}; then
echo -e "Unable to connect to dl.dasharo.com for submitting the
\rHCL report. Please recheck your internet connection."
else
LOGS_SENT="1"
fi
fi
fi

if [ -n "${LOGS_SENT}" ]; then
${CMD_DASHARO_DEPLOY} install
result=$?
if [ "$result" -ne 0 ] && [ "$result" -ne 2 ]; then
send_dts_logs ask && return 0
fi
${CMD_DASHARO_DEPLOY} install
result=$?
if [ "$result" -ne 0 ] && [ "$result" -ne 2 ]; then
return 0
fi
else
# TODO: This should be placed in dasharo-deploy:
Expand Down Expand Up @@ -1487,7 +1456,7 @@ main_menu_options() {
${CMD_DASHARO_DEPLOY} update
result=$?
if [ "$result" -ne 0 ] && [ "$result" -ne 2 ]; then
send_dts_logs ask && return 0
return 0
fi
fi
read -p "Press Enter to continue."
Expand All @@ -1501,55 +1470,11 @@ main_menu_options() {

if check_if_dasharo; then
if ! ${CMD_DASHARO_DEPLOY} restore; then
send_dts_logs ask && return 0
return 0
fi
fi
read -p "Press Enter to continue."

return 0
;;
"${DPP_KEYS_OPT}")
local _result
# Return if there was an issue when asking for credentials:
if ! get_dpp_creds; then
read -p "Press Enter to continue."
return 0
fi

# Try to log in using available DPP credentials, start loop over if login
# was not successful:
if ! login_to_dpp_server; then
echo "Cannot log in to DPP server."
read -p "Press Enter to continue"
return 0
fi

# Check for Dasharo Firmware for the current platform, continue to
# packages after checking:
check_for_dasharo_firmware
_result=$?
echo "Your credentials give access to:"
echo -n "Dasharo Pro Package (DPP): "
if [ $_result -eq 0 ]; then
# FIXME: what if credentials have access to
# firmware, but check_for_dasharo_firmware will not detect any platform?
# According to check_for_dasharo_firmware it will return 1 in both
# cases which means that we cannot detect such case.
print_ok "YES"
else
echo "NO"
fi

echo -n "DTS Extensions: "

if check_dts_extensions_access; then
print_ok "YES"
check_avail_dpp_packages && install_all_dpp_packages && parse_for_premium_submenu
else
echo "NO"
fi

read -p "Press Enter to continue."
return 0
;;
"${DPP_SUBMENU_OPT}")
Expand All @@ -1572,18 +1497,6 @@ show_footer() {
else
echo -ne "${RED}${SSH_OPT_UP}${NORMAL} to launch SSH server ${NORMAL}"
fi
if [ "${SEND_LOGS_ACTIVE}" == "true" ]; then
echo -e "${RED}${SEND_LOGS_OPT}${NORMAL} to disable sending DTS logs ${NORMAL}"
else
echo -e "${RED}${SEND_LOGS_OPT}${NORMAL} to enable sending DTS logs ${NORMAL}"
fi
if [ -n "${DPP_IS_LOGGED}" ]; then
if [ "${DISPLAY_CREDENTIALS}" == "true" ]; then
echo -e "${RED}${TOGGLE_DISP_CRED_OPT_UP}${NORMAL} to hide DPP credentials ${NORMAL}"
else
echo -e "${RED}${TOGGLE_DISP_CRED_OPT_UP}${NORMAL} to display DPP credentials ${NORMAL}"
fi
fi
echo -ne "${YELLOW}\nEnter an option:${NORMAL}"
}

Expand Down Expand Up @@ -1612,7 +1525,6 @@ footer_options() {
clear
echo "Entering shell, to leave type exit and press Enter or press LCtrl+D"
echo ""
send_dts_logs
stop_logging
${CMD_SHELL}
start_logging
Expand All @@ -1622,27 +1534,11 @@ footer_options() {
unset DPP_SUBMENU_ACTIVE
;;
"${POWEROFF_OPT_UP}" | "${POWEROFF_OPT_LOW}")
send_dts_logs
${POWEROFF}
;;
"${REBOOT_OPT_UP}" | "${REBOOT_OPT_LOW}")
send_dts_logs
${REBOOT}
;;
"${SEND_LOGS_OPT}" | "${SEND_LOGS_OPT_LOW}")
if [ "${SEND_LOGS_ACTIVE}" == "true" ]; then
unset SEND_LOGS_ACTIVE
else
export SEND_LOGS_ACTIVE="true"
fi
;;
"${TOGGLE_DISP_CRED_OPT_UP}" | "${TOGGLE_DISP_CRED_OPT_LOW}")
if [ "${DISPLAY_CREDENTIALS}" == "true" ]; then
unset DISPLAY_CREDENTIALS
else
export DISPLAY_CREDENTIALS="true"
fi
;;
esac

return 1
Expand Down
78 changes: 0 additions & 78 deletions reports/dasharo-hcl-report.sh
Original file line number Diff line number Diff line change
Expand Up @@ -329,81 +329,3 @@ if [ $DEPLOY_REPORT = "false" ]; then
echo "Done! Logs saved to: $(readlink -f $filename.tar.gz)"
fi

if [ "$SEND_LOGS" = "true" ]; then
if [ $DEPLOY_REPORT = "false" ]; then
echo "Sending logs to 3mdeb MinIO"
fi

DPP_HCL_BUCKET="dasharo-hcl-reports"
PUBLIC_HCL_BUCKET="dasharo-hcl-reports-public"

if [ -f "${DPP_CREDENTIAL_FILE}" ]; then
DPP_EMAIL=$(sed -n '1p' <${DPP_CREDENTIAL_FILE} | tr -d '\n')
DPP_PASSWORD=$(sed -n '2p' <${DPP_CREDENTIAL_FILE} | tr -d '\n')

if [ -z "$DPP_EMAIL" ]; then
echo "DPP e-mail is empty"
exit 1
fi
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
exit 1
fi
fi
DPP_HCL_LINK="${DPP_HCL_BUCKET}/${DPP_EMAIL}"
ALIAS=$DPP_SERVER_USER_ALIAS
else
ALIAS="public-hcl"
if [ -z "$(mc alias list | grep ${ALIAS})" ]; then
if ! mc alias set $ALIAS $DPP_SERVER_ADDRESS $BASE_HCL_USERNAME $BASE_HCL_PASSWORD >>$ERR_LOG_FILE 2>&1; then
exit 1
fi
fi
DPP_HCL_LINK="${PUBLIC_HCL_BUCKET}"
fi

mc cp "$(readlink -f $filename.tar.gz)" "${ALIAS}/${DPP_HCL_LINK}/"
if [ "$?" -ne "0" ]; then
echo "Failed to send logs to MinIO"
exit 1
fi
if [ $DEPLOY_REPORT = "false" ]; then
echo "Thank you for supporting Dasharo!"
fi
fi

echo -e \
"-----------------------------------------------------------------------------\r
Would you like to contribute to the \"Hardware for Linux\" project?\r
it is an open source project that that anonymously collects hardware details\r
of Linux-powered computers over the world and helps people to collaboratively\r
debug hardware related issues, check for Linux-compatibility and find drivers.\r
-----------------------------------------------------------------------------\r
You can find more about it here:\r
https://linux-hardware.org/\r
https://github.com/linuxhw/hw-probe\r
-----------------------------------------------------------------------------\r
Do you want to participate in this project?\r
(if you answer \"yes\", then command hw-probe --all --upload will be ran, in \r
order to participate)\r
"

read -p "[N/y] "
case ${REPLY} in
yes | y | Y | Yes | YES)
$HW_PROBE -all -upload
if [ $? -eq 0 ]; then
echo "Thank you for contributing to the \"Hardware for Linux\" project!"
else
echo "couldn't probe/upload. Check your internet connection..."
exit 1
fi
;;
*)
echo -e \
"Please consider contributing to the \"Hardware for Linux\" project in the future.\r
All you have to do is run this command:\r
hw-probe --all --upload\r
"
;;
esac
Loading