From e1f43041cd3d5ba18ee7e9ff296a369f0200e6c5 Mon Sep 17 00:00:00 2001 From: Alexander Date: Fri, 23 Feb 2024 20:06:15 +0100 Subject: [PATCH] update scripts --- fwdl.sh | 21 +++++---------------- unpack.sh | 20 +++++--------------- 2 files changed, 10 insertions(+), 31 deletions(-) diff --git a/fwdl.sh b/fwdl.sh index 1196b57..8232727 100755 --- a/fwdl.sh +++ b/fwdl.sh @@ -1,10 +1,9 @@ #!/bin/bash -# global definitions: -RED='\033[0;31m' -GREEN='\033[0;32m' -BROWN='\033[0;33m' -NC='\033[0m' +project_root="$PWD" + +# Source the utils.sh file +source "$project_root/TOOLS/helpers/utils.sh" "$project_root" # check the parameters for a model and version if [ $# != 2 ]; then @@ -28,17 +27,7 @@ if [ "$par_models" = "all" ] || [ "$par_models" = "ALL" ]; then fi # check the required tools -TOOL_LIST="curl wc awk" -for tool_name in $TOOL_LIST; do - echo "Checking tool: $tool_name" - tool_path=$(which "$tool_name") - if [ -z "$tool_path" ]; then - if [ ! -f "TOOLS/$tool_name" ]; then - echo -e "${RED}ERROR: Missing tool '$tool_name' ${NC}" - exit 3 - fi - fi -done +check_tools "curl wc awk" for par_model in $par_models; do diff --git a/unpack.sh b/unpack.sh index a9d9ddc..34c29a3 100755 --- a/unpack.sh +++ b/unpack.sh @@ -1,9 +1,9 @@ #!/bin/bash -# global definitions: -RED='\033[0;31m' -GREEN='\033[0;32m' -NC='\033[0m' +project_root="$PWD" + +# Source the utils.sh file +source "$project_root/TOOLS/helpers/utils.sh" "$project_root" # check the number of arguments if (($# != 1)); then @@ -29,17 +29,7 @@ if [ "$UPDATE_FILE_EXT" != "bin" ] && [ "$UPDATE_FILE_EXT" != "swu" ] && [ "$UPD fi # check the required tools -TOOL_LIST="cpio unsquashfs unzip ack2_swu_decrypt.py python3" -for tool_name in $TOOL_LIST; do - echo "Checking tool: $tool_name" - tool_path=$(which "$tool_name") - if [ -z "$tool_path" ]; then - if [ ! -f "TOOLS/$tool_name" ]; then - echo -e "${RED}ERROR: Missing tool '$tool_name' ${NC}" - exit 3 - fi - fi -done +check_tools "cpio unsquashfs unzip ack2_swu_decrypt.py python3" # set the custom decrypt tool DECRYPT_TOOL=$(which "ack2_swu_decrypt.py")