diff --git a/RESOURCES/OPTIONS/fswebcam/fswebcam.sh b/RESOURCES/OPTIONS/fswebcam/fswebcam.sh index 4f8e230..8956cdb 100755 --- a/RESOURCES/OPTIONS/fswebcam/fswebcam.sh +++ b/RESOURCES/OPTIONS/fswebcam/fswebcam.sh @@ -14,19 +14,14 @@ project_root="$1" fswebcam_package="$2" # check the required tools -TOOL_LIST=("unzip") -i=0 -part_num=${#TOOL_LIST[*]} -while [ $i -lt $((part_num)) ]; do - echo "Checking tool: ${TOOL_LIST[$i]}" - t=$(which "${TOOL_LIST[$i]}") - if [ -z "$t" ]; then - if [ ! -f "TOOLS/${TOOL_LIST[$i]}" ]; then - echo -e "${RED}ERROR: Missing tool '${TOOL_LIST[$i]}' ${NC}" - exit 2 - fi +TOOL_LIST="unzip" +for tool_name in $TOOL_LIST; do + echo "Checking tool: $tool_name" + tool_path=$(which "$tool_name") + if [ -z "$tool_path" ]; then + echo -e "${RED}ERROR: Missing tool '$tool_name' ${NC}" + exit 1 fi - i=$(($i + 1)) done # check the project root folder diff --git a/RESOURCES/OPTIONS/opkg/opkg.sh b/RESOURCES/OPTIONS/opkg/opkg.sh index e5b4c30..4d0a26c 100755 --- a/RESOURCES/OPTIONS/opkg/opkg.sh +++ b/RESOURCES/OPTIONS/opkg/opkg.sh @@ -14,19 +14,14 @@ project_root="$1" opkg_package="$2" # check the required tools -TOOL_LIST=("unzip") -i=0 -part_num=${#TOOL_LIST[*]} -while [ $i -lt $((part_num)) ]; do - echo "Checking tool: ${TOOL_LIST[$i]}" - t=$(which "${TOOL_LIST[$i]}") - if [ -z "$t" ]; then - if [ ! -f "TOOLS/${TOOL_LIST[$i]}" ]; then - echo -e "${RED}ERROR: Missing tool '${TOOL_LIST[$i]}' ${NC}" - exit 2 - fi +TOOL_LIST="unzip" +for tool_name in $TOOL_LIST; do + echo "Checking tool: $tool_name" + tool_path=$(which "$tool_name") + if [ -z "$tool_path" ]; then + echo -e "${RED}ERROR: Missing tool '$tool_name' ${NC}" + exit 1 fi - i=$(($i + 1)) done # check the project root folder diff --git a/RESOURCES/OPTIONS/python/python.sh b/RESOURCES/OPTIONS/python/python.sh index 4599e7d..bd8f204 100755 --- a/RESOURCES/OPTIONS/python/python.sh +++ b/RESOURCES/OPTIONS/python/python.sh @@ -14,19 +14,14 @@ project_root="$1" python_package="$2" # check the required tools -TOOL_LIST=("unzip") -i=0 -part_num=${#TOOL_LIST[*]} -while [ $i -lt $((part_num)) ]; do - echo "Checking tool: ${TOOL_LIST[$i]}" - t=$(which "${TOOL_LIST[$i]}") - if [ -z "$t" ]; then - if [ ! -f "$project_root/TOOLS/${TOOL_LIST[$i]}" ]; then - echo -e "${RED}ERROR: Missing tool '${TOOL_LIST[$i]}' ${NC}" - exit 2 - fi +TOOL_LIST="unzip" +for tool_name in $TOOL_LIST; do + echo "Checking tool: $tool_name" + tool_path=$(which "$tool_name") + if [ -z "$tool_path" ]; then + echo -e "${RED}ERROR: Missing tool '$tool_name' ${NC}" + exit 1 fi - i=$(($i + 1)) done # check the project root folder diff --git a/RESOURCES/OPTIONS/ssh/ssh.sh b/RESOURCES/OPTIONS/ssh/ssh.sh index d242838..6e70efd 100755 --- a/RESOURCES/OPTIONS/ssh/ssh.sh +++ b/RESOURCES/OPTIONS/ssh/ssh.sh @@ -14,19 +14,14 @@ project_root="$1" ssh_package="$2" # check the required tools -TOOL_LIST=("unzip") -i=0 -part_num=${#TOOL_LIST[*]} -while [ $i -lt $((part_num)) ]; do - echo "Checking tool: ${TOOL_LIST[$i]}" - t=$(which "${TOOL_LIST[$i]}") - if [ -z "$t" ]; then - if [ ! -f "TOOLS/${TOOL_LIST[$i]}" ]; then - echo -e "${RED}ERROR: Missing tool '${TOOL_LIST[$i]}' ${NC}" - exit 2 - fi +TOOL_LIST="unzip" +for tool_name in $TOOL_LIST; do + echo "Checking tool: $tool_name" + tool_path=$(which "$tool_name") + if [ -z "$tool_path" ]; then + echo -e "${RED}ERROR: Missing tool '$tool_name' ${NC}" + exit 1 fi - i=$(($i + 1)) done # check the project root folder diff --git a/RESOURCES/OPTIONS/uart/uart.sh b/RESOURCES/OPTIONS/uart/uart.sh index d4a665b..a49de95 100755 --- a/RESOURCES/OPTIONS/uart/uart.sh +++ b/RESOURCES/OPTIONS/uart/uart.sh @@ -14,19 +14,14 @@ project_root="$1" uart_package="$2" # check the required tools -TOOL_LIST=("unzip") -i=0 -part_num=${#TOOL_LIST[*]} -while [ $i -lt $((part_num)) ]; do - echo "Checking tool: ${TOOL_LIST[$i]}" - t=$(which "${TOOL_LIST[$i]}") - if [ -z "$t" ]; then - if [ ! -f "TOOLS/${TOOL_LIST[$i]}" ]; then - echo -e "${RED}ERROR: Missing tool '${TOOL_LIST[$i]}' ${NC}" - exit 2 - fi +TOOL_LIST="unzip" +for tool_name in $TOOL_LIST; do + echo "Checking tool: $tool_name" + tool_path=$(which "$tool_name") + if [ -z "$tool_path" ]; then + echo -e "${RED}ERROR: Missing tool '$tool_name' ${NC}" + exit 1 fi - i=$(($i + 1)) done # check the project root folder diff --git a/RESOURCES/OPTIONS/webcam/webcam.sh b/RESOURCES/OPTIONS/webcam/webcam.sh index 5be9373..2f03d95 100755 --- a/RESOURCES/OPTIONS/webcam/webcam.sh +++ b/RESOURCES/OPTIONS/webcam/webcam.sh @@ -16,28 +16,24 @@ webcam_package="$2" # check the required tools app_version_tool=$(which app_version.sh) app_model_tool=$(which app_model.sh) -TOOL_LIST=("unzip" "app_version.sh" "app_model.sh") -i=0 -part_num=${#TOOL_LIST[*]} -while [ $i -lt $((part_num)) ]; do - toolname=${TOOL_LIST[$i]} - echo "Checking tool: $toolname" - tpath=$(which "$toolname") - if [ -z "$tpath" ]; then - local_tool_path="$project_root/TOOLS/$toolname" +TOOL_LIST="unzip app_version.sh app_model.sh" +for tool_name in $TOOL_LIST; do + echo "Checking tool: $tool_name" + tool_path=$(which "$tool_name") + if [ -z "$tool_path" ]; then + local_tool_path="$project_root/TOOLS/$tool_name" if [ ! -f "$local_tool_path" ]; then - echo -e "${RED}ERROR: Missing tool '$toolname' ${NC}" + echo -e "${RED}ERROR: Missing tool '$tool_name' ${NC}" exit 2 else - if [ "$toolname" == "app_version.sh" ]; then + if [ "$tool_name" == "app_version.sh" ]; then app_version_tool="$local_tool_path" fi - if [ "$toolname" == "app_model.sh" ]; then + if [ "$tool_name" == "app_model.sh" ]; then app_model_tool="$local_tool_path" fi fi fi - i=$(($i + 1)) done # check the project root folder @@ -95,23 +91,23 @@ if [ "$app_ver" == "3.0.9" ]; then sed -i 's/video4linux/videoXlinux/g' "$def_target" if [ "$app_model" == "K2Pro" ]; then # stop the app to log the message 'cannot open video' - printf "\x00\xf0\x20\xe3" | dd of="$def_target" bs=1 seek=2339112 conv=notrunc &>>/dev/null + printf "\x00\xf0\x20\xe3" | dd of="$def_target" bs=1 seek=2339112 conv=notrunc # slow captive portal commmunication - printf "\xff\x8f\x0f\xe3" | dd of="$def_target" bs=1 seek=63492 conv=notrunc &>>/dev/null + printf "\xff\x8f\x0f\xe3" | dd of="$def_target" bs=1 seek=63492 conv=notrunc exit 0 fi if [ "$app_model" == "K2Plus" ]; then # stop the app to log the message 'cannot open video' - printf "\x00\xf0\x20\xe3" | dd of="$def_target" bs=1 seek=2339152 conv=notrunc &>>/dev/null + printf "\x00\xf0\x20\xe3" | dd of="$def_target" bs=1 seek=2339152 conv=notrunc # slow captive portal commmunication - printf "\xff\x8f\x0f\xe3" | dd of="$def_target" bs=1 seek=63492 conv=notrunc &>>/dev/null + printf "\xff\x8f\x0f\xe3" | dd of="$def_target" bs=1 seek=63492 conv=notrunc exit 0 fi if [ "$app_model" == "K2Max" ]; then # stop the app to log the message 'cannot open video' - printf "\x00\xf0\x20\xe3" | dd of="$def_target" bs=1 seek=2339152 conv=notrunc &>>/dev/null + printf "\x00\xf0\x20\xe3" | dd of="$def_target" bs=1 seek=2339152 conv=notrunc # slow captive portal commmunication - printf "\xff\x8f\x0f\xe3" | dd of="$def_target" bs=1 seek=63492 conv=notrunc &>>/dev/null + printf "\xff\x8f\x0f\xe3" | dd of="$def_target" bs=1 seek=63492 conv=notrunc exit 0 fi fi diff --git a/fwdl.sh b/fwdl.sh index 99f2ba0..7b77b23 100755 --- a/fwdl.sh +++ b/fwdl.sh @@ -22,19 +22,16 @@ if [ "$par_model" != "K2Pro" ] && [ "$par_model" != "K2Plus" ] && [ "$par_model" fi # check the required tools -TOOL_LIST=("curl" "wc" "awk") -i=0 -part_num=${#TOOL_LIST[*]} -while [ $i -lt $((part_num)) ]; do - echo "Checking tool: ${TOOL_LIST[$i]}" - t=$(which "${TOOL_LIST[$i]}") - if [ -z "$t" ]; then - if [ ! -f "TOOLS/${TOOL_LIST[$i]}" ]; then - echo -e "${RED}ERROR: Missing tool '${TOOL_LIST[$i]}' ${NC}" - exit 2 +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 - i=$(($i + 1)) done url_bin="https://cdn.cloud-universe.anycubic.com/ota/${par_model}/AC104_${par_model}_1.1.0_${par_version}_update.bin" diff --git a/pack.sh b/pack.sh index caa0295..c3a5634 100755 --- a/pack.sh +++ b/pack.sh @@ -9,17 +9,14 @@ NC='\033[0m' FILES="sw-description sw-description.sig boot-resource uboot boot0 kernel rootfs dsp0 cpio_item_md5" # check the required tools -TOOL_LIST=("md5sum" "openssl" "sha256sum" "mksquashfs") -i=0 -part_num=${#TOOL_LIST[*]} -while [ $i -lt $((part_num)) ]; do - echo "Checking tool: ${TOOL_LIST[$i]}" - t=$(which "${TOOL_LIST[$i]}") - if [ -z "$t" ]; then - echo -e "${RED}ERROR: Missing tool '${TOOL_LIST[$i]}' ${NC}" +TOOL_LIST="md5sum openssl sha256sum mksquashfs" +for tool_name in $TOOL_LIST; do + echo "Checking tool: $tool_name" + tool_path=$(which "$tool_name") + if [ -z "$tool_path" ]; then + echo -e "${RED}ERROR: Missing tool '$tool_name' ${NC}" exit 1 fi - i=$(($i + 1)) done # remove the last created update diff --git a/patch.sh b/patch.sh index fc480a6..e89cf4c 100755 --- a/patch.sh +++ b/patch.sh @@ -27,19 +27,14 @@ if [ ! -f "$optionsfile" ]; then fi # check the required tools -TOOL_LIST=("awk") -i=0 -part_num=${#TOOL_LIST[*]} -while [ $i -lt $((part_num)) ]; do - echo "Checking tool: ${TOOL_LIST[$i]}" - t=$(which "${TOOL_LIST[$i]}") - if [ -z "$t" ]; then - if [ ! -f "TOOLS/${TOOL_LIST[$i]}" ]; then - echo -e "${RED}ERROR: Missing tool '${TOOL_LIST[$i]}' ${NC}" - exit 2 - fi +TOOL_LIST="awk" +for tool_name in $TOOL_LIST; do + echo "Checking tool: $tool_name" + tool_path=$(which "$tool_name") + if [ -z "$tool_path" ]; then + echo -e "${RED}ERROR: Missing tool '$tool_name' ${NC}" + exit 1 fi - i=$(($i + 1)) done # remove the old result file for the installed options diff --git a/unpack.sh b/unpack.sh index 38e1311..4cc91e9 100755 --- a/unpack.sh +++ b/unpack.sh @@ -29,19 +29,16 @@ 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") -i=0 -part_num=${#TOOL_LIST[*]} -while [ $i -lt $((part_num)) ]; do - echo "Checking tool: ${TOOL_LIST[$i]}" - t=$(which "${TOOL_LIST[$i]}") - if [ -z "$t" ]; then - if [ ! -f "TOOLS/${TOOL_LIST[$i]}" ]; then - echo -e "${RED}ERROR: Missing tool '${TOOL_LIST[$i]}' ${NC}" +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 - i=$(($i + 1)) done # set the custom decrypt tool