Skip to content

Commit

Permalink
Fix indents in scripts
Browse files Browse the repository at this point in the history
Signed-off-by: Pawel Langowski <[email protected]>
  • Loading branch information
PLangowski committed Oct 18, 2024
1 parent feb01cf commit efade0c
Show file tree
Hide file tree
Showing 10 changed files with 1,393 additions and 1,406 deletions.
4 changes: 2 additions & 2 deletions include/dts-environment.sh
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ DTS_LOGS_PASSWORD="/w\J&<y1"

# set custom localization for PGP keys
if [ -d /home/root/.dasharo-gnupg ]; then
GNUPGHOME=/home/root/.dasharo-gnupg
GNUPGHOME=/home/root/.dasharo-gnupg

export GNUPGHOME
export GNUPGHOME
fi
1,896 changes: 945 additions & 951 deletions include/dts-functions.sh

Large diffs are not rendered by default.

54 changes: 27 additions & 27 deletions include/dts-subscription.sh
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@ 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')
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"

# Check the board information:
Expand Down Expand Up @@ -80,14 +80,14 @@ get_dpp_creds() {
# 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 ${TMP_CLOUDSEND_LOGS_URL} >${DPP_credential_file}
echo ${TMP_CLOUDSEND_DOWNLOAD_URL} >>${DPP_credential_file}
echo ${TMP_CLOUDSEND_PASSWORD} >>${DPP_credential_file}

print_ok "Dasharo DPP credentials have been saved"
}

login_to_dpp_server(){
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
mc alias set $DPP_SERVER_USER_ALIAS $DPP_SERVER_ADDRESS $CLOUDSEND_DOWNLOAD_URL $CLOUDSEND_PASSWORD || return 1
Expand All @@ -100,7 +100,7 @@ login_to_dpp_server(){
return 0
}

subscription_routine(){
subscription_routine() {
# This function contains Subscription-related code which needs to be executed
# several times. Currently it is called only in /usr/sbin/dts script at every
# start of menu rendering loop.
Expand All @@ -115,9 +115,9 @@ subscription_routine(){
# 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')
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"
export DPP_IS_LOGGED="true"
else
Expand All @@ -134,17 +134,17 @@ subscription_routine(){
return 0
}

check_dasharo_package_env(){
check_dasharo_package_env() {
[ -d $DPP_PACKAGE_MANAGER_DIR ] || mkdir -p $DPP_PACKAGE_MANAGER_DIR
[ -d $DPP_PACKAGES_SCRIPTS_PATH ] || mkdir -p $DPP_PACKAGES_SCRIPTS_PATH

return 0
}

update_package_list(){
update_package_list() {
check_dasharo_package_env

mc find --json --name "*.rpm" $DPP_SERVER_USER_ALIAS > $DPP_AVAIL_PACKAGES_LIST
mc find --json --name "*.rpm" $DPP_SERVER_USER_ALIAS >$DPP_AVAIL_PACKAGES_LIST

if [ $? -ne 0 ]; then
print_error "Unable to get package list!"
Expand All @@ -153,7 +153,7 @@ update_package_list(){
return 0
}

download_dpp_package(){
download_dpp_package() {
local package_name=$1

# Make sure all paths exist:
Expand Down Expand Up @@ -181,7 +181,7 @@ download_dpp_package(){
return 0
}

install_dpp_package(){
install_dpp_package() {
local package_name=$1

check_dasharo_package_env
Expand All @@ -208,7 +208,7 @@ install_dpp_package(){
return 0
}

install_all_dpp_packages(){
install_all_dpp_packages() {
echo "Installing available DPP packages..."

update_package_list || return 1
Expand All @@ -233,7 +233,7 @@ install_all_dpp_packages(){
return 0
}

check_avail_dpp_packages(){
check_avail_dpp_packages() {
echo "Checking for available DPP packages..."
AVAILABLE_PACKAGES=$(mc find --name "*.rpm" $DPP_SERVER_USER_ALIAS)

Expand Down Expand Up @@ -266,26 +266,26 @@ parse_for_premium_submenu() {

# Create the JSON file only if any script have been found, this will be a
# signal to render premium submenu:
[ -f "$DPP_SUBMENU_JSON" ] || echo '[]' > "$DPP_SUBMENU_JSON"
[ -f "$DPP_SUBMENU_JSON" ] || echo '[]' >"$DPP_SUBMENU_JSON"

local script_name
script_name=$(basename "$script")

# Add a new entry to the JSON file
json_data=$(jq --arg name "$script_name" --argjson pos "$position" \
'. += [{"file_name": $name, "file_menu_position": $pos}]' <<< "$json_data")
'. += [{"file_name": $name, "file_menu_position": $pos}]' <<<"$json_data")

# Increment highest position for next script
position=$((position + 1))
done

# Save updated JSON data
[ -f "$DPP_SUBMENU_JSON" ] && echo "$json_data" | jq '.' > "$DPP_SUBMENU_JSON"
[ -f "$DPP_SUBMENU_JSON" ] && echo "$json_data" | jq '.' >"$DPP_SUBMENU_JSON"

return 0
}

show_dpp_submenu(){
show_dpp_submenu() {
# This menu is being rendered dynamically by parsing scripts from
# DPP_PACKAGES_SCRIPTS_PATH. These scripts are being installed by DPP
# packages.
Expand All @@ -306,21 +306,21 @@ show_dpp_submenu(){
# Iterate over each JSON object:
while IFS= read -r item; do
local script_name
script_name=$(jq -r '.file_name' <<< "$item")
file_menu_position=$(jq -r '.file_menu_position' <<< "$item")
script_name=$(jq -r '.file_name' <<<"$item")
file_menu_position=$(jq -r '.file_menu_position' <<<"$item")

local script_path="$DPP_PACKAGES_SCRIPTS_PATH/$script_name"

bash "$script_path" menu_point "$file_menu_position"

done <<< "$json_data"
done <<<"$json_data"

echo -e "${BLUE}**${YELLOW} ${BACK_TO_MAIN_MENU_UP})${BLUE} Return to main menu${NORMAL}"

return 0
}

dpp_submenu_options(){
dpp_submenu_options() {
local OPTION=$1
local file_menu_position
local script
Expand All @@ -342,7 +342,7 @@ dpp_submenu_options(){
[ -z "$script" ] && return 1

local script_name
script_name=$(jq -r '.file_name' <<< "$script")
script_name=$(jq -r '.file_name' <<<"$script")

local script_path="$DPP_PACKAGES_SCRIPTS_PATH/$script_name"

Expand Down
Loading

0 comments on commit efade0c

Please sign in to comment.