2023-09-19 11:25:58 +02:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
2024-04-10 11:10:52 +02:00
|
|
|
# SPDX-FileCopyrightText: 2024 3mdeb <contact@3mdeb.com>
|
|
|
|
|
#
|
|
|
|
|
# SPDX-License-Identifier: Apache-2.0
|
|
|
|
|
|
2024-01-26 13:55:59 +01:00
|
|
|
SBIN_DIR="/usr/sbin"
|
2024-09-11 12:29:42 +02:00
|
|
|
FUM_EFIVAR="/sys/firmware/efi/efivars/FirmwareUpdateMode-d15b327e-ff2d-4fc1-abf6-c12bd08c1359"
|
2023-09-19 11:25:58 +02:00
|
|
|
|
2024-01-26 13:55:59 +01:00
|
|
|
export DTS_FUNCS="$SBIN_DIR/dts-functions.sh"
|
|
|
|
|
export DTS_ENV="$SBIN_DIR/dts-environment.sh"
|
2024-06-20 15:41:45 +02:00
|
|
|
export DTS_SUBS="$SBIN_DIR/dts-subscription.sh"
|
2024-10-14 12:40:24 +02:00
|
|
|
export DTS_HAL="$SBIN_DIR/dts-hal.sh"
|
|
|
|
|
export DTS_MOCK_COMMON="$SBIN_DIR/common-mock-func.sh"
|
2024-12-18 17:02:25 +01:00
|
|
|
export BASH_ENV="$SBIN_DIR/logging"
|
2025-01-10 10:55:00 +01:00
|
|
|
export TMP_LOG_DIR="/tmp/logs"
|
2024-12-18 17:02:25 +01:00
|
|
|
export ERR_LOG_FILE_REALPATH
|
2024-12-13 18:46:43 +01:00
|
|
|
export DTS_LOG_FILE
|
|
|
|
|
export DTS_VERBOSE_LOG_FILE
|
2024-12-18 17:02:25 +01:00
|
|
|
export ERR_LOG_FILE
|
2024-12-13 02:44:57 +01:00
|
|
|
export SHELLOPTS
|
|
|
|
|
|
2025-01-09 13:53:35 +01:00
|
|
|
mkdir -p "$TMP_LOG_DIR"
|
2024-12-20 11:04:00 +01:00
|
|
|
# $ERR_LOG_FILE is fd that can only be written to: '>()'. To copy logs
|
|
|
|
|
# we need underlying file that can be copied
|
2024-12-18 17:02:25 +01:00
|
|
|
ERR_LOG_FILE_REALPATH="/var/local/dts-err_$(basename "$(tty)").log"
|
2025-01-09 13:53:35 +01:00
|
|
|
DTS_LOG_FILE="$TMP_LOG_DIR/dts_$(basename "$(tty)").log"
|
|
|
|
|
DTS_VERBOSE_LOG_FILE="$TMP_LOG_DIR/dts-verbose_$(basename "$(tty)").log"
|
2024-12-13 18:46:43 +01:00
|
|
|
|
2024-12-13 02:44:57 +01:00
|
|
|
# shellcheck source=./logging
|
|
|
|
|
source "$BASH_ENV"
|
2024-12-18 17:02:25 +01:00
|
|
|
start_trace_logging
|
|
|
|
|
start_logging
|
|
|
|
|
if [ -z "$ERR_LOG_FILE" ]; then
|
2025-04-15 14:48:13 +02:00
|
|
|
# pass everything written to $ERR_LOG_FILE to logger function and save it's
|
|
|
|
|
# output to $ERR_LOG_FILE_REALPATH file
|
|
|
|
|
exec {ERR_LOG_FILE}> >(logger >>"$ERR_LOG_FILE_REALPATH")
|
|
|
|
|
ERR_LOG_FILE="/proc/$$/fd/$ERR_LOG_FILE"
|
2024-12-18 17:02:25 +01:00
|
|
|
fi
|
2024-01-26 13:55:59 +01:00
|
|
|
|
2024-10-14 18:54:44 +02:00
|
|
|
# shellcheck source=../include/dts-environment.sh
|
|
|
|
|
source $DTS_ENV
|
|
|
|
|
# shellcheck source=../include/dts-functions.sh
|
|
|
|
|
source $DTS_FUNCS
|
2024-10-14 12:40:24 +02:00
|
|
|
# shellcheck source=../include/hal/dts-hal.sh
|
|
|
|
|
source $DTS_HAL
|
|
|
|
|
|
2025-08-11 16:20:49 +02:00
|
|
|
mkdir -p "$TEMP_DIR"
|
|
|
|
|
|
2024-10-22 15:46:22 +02:00
|
|
|
if [ -f $FUM_EFIVAR ]; then
|
2025-04-15 14:48:13 +02:00
|
|
|
$SBIN_DIR/dasharo-deploy update fum
|
2023-09-19 11:25:58 +02:00
|
|
|
else
|
2025-04-15 14:48:13 +02:00
|
|
|
$SBIN_DIR/dts
|
2023-09-19 11:25:58 +02:00
|
|
|
fi
|