From 2fa48971f0fc8b4d31ad2788bed608e77fbac909 Mon Sep 17 00:00:00 2001 From: AGG2017 Date: Sat, 17 Feb 2024 20:09:08 -0500 Subject: [PATCH] Added app_net_ready option --- .../OPTIONS/app_net_ready/10s/3.0.9.K2Max | 1 + .../OPTIONS/app_net_ready/10s/3.0.9.K2Plus | 1 + .../OPTIONS/app_net_ready/10s/3.0.9.K2Pro | 1 + .../OPTIONS/app_net_ready/20s/3.0.9.K2Max | 1 + .../OPTIONS/app_net_ready/20s/3.0.9.K2Plus | 1 + .../OPTIONS/app_net_ready/20s/3.0.9.K2Pro | 1 + .../OPTIONS/app_net_ready/30s/3.0.9.K2Max | 1 + .../OPTIONS/app_net_ready/30s/3.0.9.K2Plus | 1 + .../OPTIONS/app_net_ready/30s/3.0.9.K2Pro | 1 + .../OPTIONS/app_net_ready/5s/3.0.9.K2Max | 1 + .../OPTIONS/app_net_ready/5s/3.0.9.K2Plus | 1 + .../OPTIONS/app_net_ready/5s/3.0.9.K2Pro | 1 + .../OPTIONS/app_net_ready/60s/3.0.9.K2Max | 1 + .../OPTIONS/app_net_ready/60s/3.0.9.K2Plus | 1 + .../OPTIONS/app_net_ready/60s/3.0.9.K2Pro | 1 + .../OPTIONS/app_net_ready/app_net_ready.sh | 81 +++++++++++++++++++ options.cfg | 6 ++ pack.sh | 7 +- 18 files changed, 106 insertions(+), 3 deletions(-) create mode 100644 RESOURCES/OPTIONS/app_net_ready/10s/3.0.9.K2Max create mode 100644 RESOURCES/OPTIONS/app_net_ready/10s/3.0.9.K2Plus create mode 100644 RESOURCES/OPTIONS/app_net_ready/10s/3.0.9.K2Pro create mode 100644 RESOURCES/OPTIONS/app_net_ready/20s/3.0.9.K2Max create mode 100644 RESOURCES/OPTIONS/app_net_ready/20s/3.0.9.K2Plus create mode 100644 RESOURCES/OPTIONS/app_net_ready/20s/3.0.9.K2Pro create mode 100644 RESOURCES/OPTIONS/app_net_ready/30s/3.0.9.K2Max create mode 100644 RESOURCES/OPTIONS/app_net_ready/30s/3.0.9.K2Plus create mode 100644 RESOURCES/OPTIONS/app_net_ready/30s/3.0.9.K2Pro create mode 100644 RESOURCES/OPTIONS/app_net_ready/5s/3.0.9.K2Max create mode 100644 RESOURCES/OPTIONS/app_net_ready/5s/3.0.9.K2Plus create mode 100644 RESOURCES/OPTIONS/app_net_ready/5s/3.0.9.K2Pro create mode 100644 RESOURCES/OPTIONS/app_net_ready/60s/3.0.9.K2Max create mode 100644 RESOURCES/OPTIONS/app_net_ready/60s/3.0.9.K2Plus create mode 100644 RESOURCES/OPTIONS/app_net_ready/60s/3.0.9.K2Pro create mode 100755 RESOURCES/OPTIONS/app_net_ready/app_net_ready.sh diff --git a/RESOURCES/OPTIONS/app_net_ready/10s/3.0.9.K2Max b/RESOURCES/OPTIONS/app_net_ready/10s/3.0.9.K2Max new file mode 100644 index 0000000..3a04b57 --- /dev/null +++ b/RESOURCES/OPTIONS/app_net_ready/10s/3.0.9.K2Max @@ -0,0 +1 @@ +\x10\x87\x02\xe3@63492 diff --git a/RESOURCES/OPTIONS/app_net_ready/10s/3.0.9.K2Plus b/RESOURCES/OPTIONS/app_net_ready/10s/3.0.9.K2Plus new file mode 100644 index 0000000..3a04b57 --- /dev/null +++ b/RESOURCES/OPTIONS/app_net_ready/10s/3.0.9.K2Plus @@ -0,0 +1 @@ +\x10\x87\x02\xe3@63492 diff --git a/RESOURCES/OPTIONS/app_net_ready/10s/3.0.9.K2Pro b/RESOURCES/OPTIONS/app_net_ready/10s/3.0.9.K2Pro new file mode 100644 index 0000000..3a04b57 --- /dev/null +++ b/RESOURCES/OPTIONS/app_net_ready/10s/3.0.9.K2Pro @@ -0,0 +1 @@ +\x10\x87\x02\xe3@63492 diff --git a/RESOURCES/OPTIONS/app_net_ready/20s/3.0.9.K2Max b/RESOURCES/OPTIONS/app_net_ready/20s/3.0.9.K2Max new file mode 100644 index 0000000..565aefc --- /dev/null +++ b/RESOURCES/OPTIONS/app_net_ready/20s/3.0.9.K2Max @@ -0,0 +1 @@ +\x20\x8e\x04\xe3@63492 diff --git a/RESOURCES/OPTIONS/app_net_ready/20s/3.0.9.K2Plus b/RESOURCES/OPTIONS/app_net_ready/20s/3.0.9.K2Plus new file mode 100644 index 0000000..565aefc --- /dev/null +++ b/RESOURCES/OPTIONS/app_net_ready/20s/3.0.9.K2Plus @@ -0,0 +1 @@ +\x20\x8e\x04\xe3@63492 diff --git a/RESOURCES/OPTIONS/app_net_ready/20s/3.0.9.K2Pro b/RESOURCES/OPTIONS/app_net_ready/20s/3.0.9.K2Pro new file mode 100644 index 0000000..565aefc --- /dev/null +++ b/RESOURCES/OPTIONS/app_net_ready/20s/3.0.9.K2Pro @@ -0,0 +1 @@ +\x20\x8e\x04\xe3@63492 diff --git a/RESOURCES/OPTIONS/app_net_ready/30s/3.0.9.K2Max b/RESOURCES/OPTIONS/app_net_ready/30s/3.0.9.K2Max new file mode 100644 index 0000000..6b51ac7 --- /dev/null +++ b/RESOURCES/OPTIONS/app_net_ready/30s/3.0.9.K2Max @@ -0,0 +1 @@ +\x30\x85\x07\xe3@63492 diff --git a/RESOURCES/OPTIONS/app_net_ready/30s/3.0.9.K2Plus b/RESOURCES/OPTIONS/app_net_ready/30s/3.0.9.K2Plus new file mode 100644 index 0000000..6b51ac7 --- /dev/null +++ b/RESOURCES/OPTIONS/app_net_ready/30s/3.0.9.K2Plus @@ -0,0 +1 @@ +\x30\x85\x07\xe3@63492 diff --git a/RESOURCES/OPTIONS/app_net_ready/30s/3.0.9.K2Pro b/RESOURCES/OPTIONS/app_net_ready/30s/3.0.9.K2Pro new file mode 100644 index 0000000..6b51ac7 --- /dev/null +++ b/RESOURCES/OPTIONS/app_net_ready/30s/3.0.9.K2Pro @@ -0,0 +1 @@ +\x30\x85\x07\xe3@63492 diff --git a/RESOURCES/OPTIONS/app_net_ready/5s/3.0.9.K2Max b/RESOURCES/OPTIONS/app_net_ready/5s/3.0.9.K2Max new file mode 100644 index 0000000..dc9a9bb --- /dev/null +++ b/RESOURCES/OPTIONS/app_net_ready/5s/3.0.9.K2Max @@ -0,0 +1 @@ +\x88\x83\x01\xe3@63492 diff --git a/RESOURCES/OPTIONS/app_net_ready/5s/3.0.9.K2Plus b/RESOURCES/OPTIONS/app_net_ready/5s/3.0.9.K2Plus new file mode 100644 index 0000000..dc9a9bb --- /dev/null +++ b/RESOURCES/OPTIONS/app_net_ready/5s/3.0.9.K2Plus @@ -0,0 +1 @@ +\x88\x83\x01\xe3@63492 diff --git a/RESOURCES/OPTIONS/app_net_ready/5s/3.0.9.K2Pro b/RESOURCES/OPTIONS/app_net_ready/5s/3.0.9.K2Pro new file mode 100644 index 0000000..dc9a9bb --- /dev/null +++ b/RESOURCES/OPTIONS/app_net_ready/5s/3.0.9.K2Pro @@ -0,0 +1 @@ +\x88\x83\x01\xe3@63492 diff --git a/RESOURCES/OPTIONS/app_net_ready/60s/3.0.9.K2Max b/RESOURCES/OPTIONS/app_net_ready/60s/3.0.9.K2Max new file mode 100644 index 0000000..2462ca2 --- /dev/null +++ b/RESOURCES/OPTIONS/app_net_ready/60s/3.0.9.K2Max @@ -0,0 +1 @@ +\x60\x8a\x0e\xe3@63492 diff --git a/RESOURCES/OPTIONS/app_net_ready/60s/3.0.9.K2Plus b/RESOURCES/OPTIONS/app_net_ready/60s/3.0.9.K2Plus new file mode 100644 index 0000000..2462ca2 --- /dev/null +++ b/RESOURCES/OPTIONS/app_net_ready/60s/3.0.9.K2Plus @@ -0,0 +1 @@ +\x60\x8a\x0e\xe3@63492 diff --git a/RESOURCES/OPTIONS/app_net_ready/60s/3.0.9.K2Pro b/RESOURCES/OPTIONS/app_net_ready/60s/3.0.9.K2Pro new file mode 100644 index 0000000..2462ca2 --- /dev/null +++ b/RESOURCES/OPTIONS/app_net_ready/60s/3.0.9.K2Pro @@ -0,0 +1 @@ +\x60\x8a\x0e\xe3@63492 diff --git a/RESOURCES/OPTIONS/app_net_ready/app_net_ready.sh b/RESOURCES/OPTIONS/app_net_ready/app_net_ready.sh new file mode 100755 index 0000000..dd1b9ef --- /dev/null +++ b/RESOURCES/OPTIONS/app_net_ready/app_net_ready.sh @@ -0,0 +1,81 @@ +#!/bin/bash + +# global definitions: +RED='\033[0;31m' +NC='\033[0m' + +# check the parameters +if [ $# != 2 ]; then + echo "usage : $0 " + exit 1 +fi + +project_root="$1" +settings="$2" + +# check the required tools +app_version_tool=$(which app_version.sh) +app_model_tool=$(which app_model.sh) +TOOL_LIST="app_version.sh app_model.sh cut dd" +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 '$tool_name' ${NC}" + exit 2 + else + if [ "$tool_name" == "app_version.sh" ]; then + app_version_tool="$local_tool_path" + fi + if [ "$tool_name" == "app_model.sh" ]; then + app_model_tool="$local_tool_path" + fi + fi + fi +done + +# check the project root folder +if [ ! -d "$project_root" ]; then + echo -e "${RED}ERROR: Cannot find the folder '$project_root' ${NC}" + exit 3 +fi + +# check the target folder +target_folder="$project_root/unpacked/squashfs-root" +if [ ! -d "$target_folder" ]; then + echo -e "${RED}ERROR: Cannot find the target folder '$target_folder' ${NC}" + exit 4 +fi + +# try to find out the app version (like app_ver="309") +def_target="$project_root/unpacked/squashfs-root/app/app" +app_ver=$("$app_version_tool" "$def_target") +if [ $? != 0 ]; then + echo -e "${RED}ERROR: Cannot find the app version ${NC}" + exit 5 +fi + +# try to find out the model +app_model=$("$app_model_tool" "$def_target") +if [ $? != 0 ]; then + echo -e "${RED}ERROR: Cannot find the app model ${NC}" + exit 6 +fi + +# find if the selected setting file exists +settings_file="$project_root/RESOURCES/OPTIONS/app_net_ready/$settings/${app_ver}.${app_model}" +if [ ! -f "$settings_file" ]; then + echo -e "${RED}ERROR: Unsupported model and version! Cannot find the settings file '$settings_file' ${NC}" + exit 7 +fi + +# patch the app based on the model and the version +while read -r line; do + settings_data=$(echo -n "$line" | cut -d "@" -f 1) + settings_addr=$(echo -n "$line" | cut -d "@" -f 2) + printf "$settings_data" | dd of="$def_target" bs=1 seek="$settings_addr" conv=notrunc +done <"$settings_file" + +exit 0 diff --git a/options.cfg b/options.cfg index 14195ef..af2eb5f 100644 --- a/options.cfg +++ b/options.cfg @@ -60,6 +60,12 @@ webcam="default" [python] [fswebcam] # Always keep a copy of the original keys in case you want to go back to AC cloud kobra_unleashed="localhost.mr-a.de" +# Patch the app to check the captive portal URLs less often (originally every 2s) +# It is used to detect if the internet connection is established and alive +# This patch will produce less unwanted web traffic if enabled +# Available settings are: 5s, 10s, 20s, 30s and 60s +app_net_ready="30s" + # Replace some of the app images # Use it for one or more sets: app_images="set1" "set2" "set3" #app_images="set1" diff --git a/pack.sh b/pack.sh index b7c40e7..5b64226 100755 --- a/pack.sh +++ b/pack.sh @@ -89,13 +89,14 @@ echo "" # check if the auto update is possible if [ -f "$installed_options" ]; then root_pw=$(grep "root_access=" "$installed_options") - if [ -z "$root_pw" ] || [ "$root_pw" == 'root_access=""' ]; then - echo "Root access option is not installed and the auto update is not possible. Please use the USB update procedure." + ssh_option=$(grep "ssh=" "$installed_options") + if [ -z "$root_pw" ] || [ "$root_pw" == 'root_access=""' ] || [ -z "$ssh_option" ]; then + echo -e "Root access option is not installed, the root password is empty or the ssh is disabled.\nThe auto update is not possible. Please use the USB update procedure." else # Ask if the user wants to attempt to auto install the update. If yes then run the auto install script read -r -p "Do you want to attempt to auto install the update? [y/N] " response if [[ "$response" =~ ^([yY][eE][sS]|[yY])$ ]]; then - # Run AUTO_UPDATE_TOOL + # Run the auto update tool python3 "$AUTO_UPDATE_TOOL" fi fi