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")