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 fd2722c..90b3a12 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" } @@ -177,49 +176,56 @@ update_subgeo() { fi flag=false # if true, after the update is complete it will restart BFM fi - enhanced=false - update_file_name="${clash_config}" - yq_command="$(command -v yq >/dev/null 2>&1 ; echo $?)" - # If native yq dont exist - if [ "$yq_command" -eq 0 ]; then - [ -e "${data_dir}/bin/yq" ] || update_yq - 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 - enhanced=true - update_file_name="${update_file_name}.subscription" - if [ -f /data/adb/box/bin/yq ]; then - yq="${data_dir}/bin/yq" - else - yq="yq" + if ! [ -z "${subscription_url}" ]; then + enhanced=false + update_file_name="${clash_config}" + yq_command=$(command -v yq >/dev/null 2>&1 ; echo $?) + # If native yq dont exist + 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 $?) fi - fi - if [ "${bin_name}" = "clash" ] && [ "${auto_update_subscription}" = "true" ] && update_file "${update_file_name}" "${subscription_url}"; then - log debug "Downloading ${clash_config}" - # If there is a yq command, extract the proxies information from yml and output it to the clash_domestic_config file - if [ "${enhanced}" = "true" ]; then - 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} - log info "subscription success" - if [ -f "${update_file_name}.bak" ]; then - rm ${update_file_name}.bak - fi - if [ -f "${pid_file}" ] && [ "${bin_name}" = "clash" ] && [ "${meta}" = "true" ]; then - ip_port=$(awk '/external-controller:/ {print $2}' "${clash_config}") - secret=$(awk '/secret:/ {print $2}' "${clash_config}") - busybox wget --header="Authorization: Bearer ${secret}" --post-data "" -O /dev/null "http://${ip_port}/restart" # >/dev/null 2>&1 - flag=false # if it's true, after the update is complete it will restart BFM, but to update proxy_provider you don't need to restart it, just reload it on the dashboard/yacd + wc_command=$(command -v wc >/dev/null 2>&1; echo $?) + if [ "$yq_command" -eq 0 ] && [ "$wc_command" -eq 0 ]; then + enhanced=true + update_file_name="${update_file_name}.subscription" + if [ -f /data/adb/box/bin/yq ]; then + yq="${data_dir}/bin/yq" + else + yq="yq" + fi + fi + if [ "${bin_name}" = "clash" ] && [ "${auto_update_subscription}" = "true" ] && update_file "${update_file_name}" "${subscription_url}"; then + log debug "Downloading ${clash_config}" + # If there is a yq command, extract the proxies information from yml and output it to the clash_domestic_config file + if [ "${enhanced}" = "true" ]; then + 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 + fi + if [ -f "${pid_file}" ] && [ "${bin_name}" = "clash" ] && [ "${meta}" = "true" ]; then + ip_port=$(awk '/external-controller:/ {print $2}' "${clash_config}") + secret=$(awk '/secret:/ {print $2}' "${clash_config}") + busybox wget --header="Authorization: Bearer ${secret}" --post-data "" -O /dev/null "http://${ip_port}/restart" # >/dev/null 2>&1 + flag=false # if it's true, after the update is complete it will restart BFM, but to update proxy_provider you don't need to restart it, just reload it on the dashboard/yacd + else + flag=true + fi else - flag=true + log error "subscription failed" fi else - log error "subscription failed" + flag=true # if true, after the update is complete it will restart BFM fi - else - flag=true # if true, after the update is complete it will restart BFM fi + else + log warn "subscription url is empty..." fi if [ -f "${pid_file}" ] && [ "${flag}" = "true" ]; then restart_box 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"