From e6b875db9ff0280c3048d25a9b8263d8e5620c8b Mon Sep 17 00:00:00 2001 From: easterNday <849919718@qq.com> Date: Thu, 8 Jun 2023 19:03:17 +0800 Subject: [PATCH] feat: add yacd autostart settings & fix some yq bugs --- .github/workflows/del.yml | 2 +- box/scripts/box.service | 5 +++++ box/scripts/box.tool | 10 ++++++---- box/settings.ini | 1 + 4 files changed, 13 insertions(+), 5 deletions(-) diff --git a/.github/workflows/del.yml b/.github/workflows/del.yml index f2861f6..ca33a98 100755 --- a/.github/workflows/del.yml +++ b/.github/workflows/del.yml @@ -14,4 +14,4 @@ jobs: token: ${{ secrets.GITHUB_TOKEN }} repository: ${{ github.repository }} retain_days: 0 - keep_minimum_runs: 0 + keep_minimum_runs: 5 diff --git a/box/scripts/box.service b/box/scripts/box.service index c5cf139..a0296c7 100755 --- a/box/scripts/box.service +++ b/box/scripts/box.service @@ -464,6 +464,11 @@ start_box() { detected_port still_alive display_bin_pid + # Open the yacd in browser + if [ "${bin_name}" = "clash" ] && [ "${display_yacd_on_start}" = "true" ]; then + sleep 0.5 + am start -a android.intent.action.VIEW -d http://127.0.0.1:9090/ui + fi } stop_box() { diff --git a/box/scripts/box.tool b/box/scripts/box.tool index 400adf5..6b56c0e 100755 --- a/box/scripts/box.tool +++ b/box/scripts/box.tool @@ -139,7 +139,6 @@ update_yq() { *) log warn "Unsupported architecture: $(uname -m)" >&2; exit 1 ;; esac download_link="https://github.com/mikefarah/yq/releases/latest/download/yq_${platform}_${arch}" - log debug "${download_link}" update_file "${data_dir}/bin/yq" "${download_link}" chmod +x "${data_dir}/bin/yq" } @@ -174,11 +173,12 @@ update_subgeo() { fi enhanced=false update_file_name="${clash_config}" - yq_command="$(command -v yq >/dev/null 2>&1 ; echo $?)" + yq_command=$(command -v yq >/dev/null 2>&1 ; echo $?) # If native yq dont exist - if [ "$yq_command" -eq 0 ]; then + if [ "$yq_command" -eq 1 ]; then + log debug "yq command found, start to download from github" [ -e "${data_dir}/bin/yq" ] || update_yq - yq_command="$(command -v ${data_dir}/bin/yq >/dev/null 2>&1 ; echo $?)" + yq_command=$(command -v ${data_dir}/bin/yq >/dev/null 2>&1 ; echo $?) fi wc_command=$(command -v wc >/dev/null 2>&1; echo $?) if [ "$yq_command" -eq 0 ] && [ "$wc_command" -eq 0 ]; then @@ -197,6 +197,8 @@ update_subgeo() { if [ $(cat ${update_file_name} | ${yq} '.proxies' | wc -l) -gt 1 ];then ${yq} '.proxies' ${update_file_name} > ${clash_domestic_config} ${yq} -i '{"proxies": .}' ${clash_domestic_config} + # if yq & wc exist, update the file location + update_file_name="${update_file_name}.subscription" log info "subscription success" if [ -f "${update_file_name}.bak" ]; then rm ${update_file_name}.bak diff --git a/box/settings.ini b/box/settings.ini index a2bc46e..c94922b 100755 --- a/box/settings.ini +++ b/box/settings.ini @@ -73,6 +73,7 @@ system_packages_file="/data/system/packages.list" uid_list=("/data/adb/box/run/appuid.list") # clash configuration +display_yacd_on_start="false" name_clash_config="config.yaml" clash_config="${data_dir}/clash/${name_clash_config}" clash_domestic_config="${data_dir}/clash/provide/domestic.yml"