diff --git a/.github/workflows/debug.yml b/.github/workflows/debug.yml index f4aca2f..05c345b 100644 --- a/.github/workflows/debug.yml +++ b/.github/workflows/debug.yml @@ -21,12 +21,14 @@ jobs: id: get_tags run: | echo "tag=$(grep -oP 'version=\K[^ ]+' module.prop)" >> "$GITHUB_OUTPUT" - echo "date=$(date +%Y%m%d)" >> "$GITHUB_OUTPUT" + echo "version=$(git rev-parse --short HEAD)_$(date +%Y%m%d)" >> "$GITHUB_OUTPUT" + echo "versionCode=$(date +%Y%m%d)" >> "$GITHUB_OUTPUT" - name: update module.prop run: | - sed -i "s/version=.*/version=${{ steps.get_tags.outputs.tag }}_$(date +%Y%m%d_%H%M)_debug/g" module.prop - sed -i "s/versionCode=.*/versionCode=${{ steps.get_tags.outputs.date }}/g" module.prop + # sed -i "s/version=.*/version=${{ steps.get_tags.outputs.tag }}_${{ steps.get_tags.outputs.tag }}_debug/g" module.prop + sed -i "s/${{ steps.get_tags.outputs.tag }}/&_${{ steps.get_tags.outputs.version }}_debug/g" module.prop + sed -i "s/versionCode=.*/versionCode=${{ steps.get_tags.outputs.versionCode }}/g" module.prop - name: get version id: get_version @@ -55,11 +57,13 @@ jobs: id: get_tags run: | echo "tag=$(grep -oP 'version=\K[^ ]+' module.prop)" >> "$GITHUB_OUTPUT" - echo "date=$(date +%Y%m%d_%H%M)" >> "$GITHUB_OUTPUT" + echo "version=$(git rev-parse --short HEAD)_$(date +%Y%m%d)" >> "$GITHUB_OUTPUT" + echo "versionCode=$(date +%Y%m%d)" >> "$GITHUB_OUTPUT" - name: Get Version and Build run: | - sed -i "s/${{ steps.get_tags.outputs.tag }}/&_$(date +%Y%m%d_%H%M)_debug/g" module.prop + sed -i "s/${{ steps.get_tags.outputs.tag }}/&_${{ steps.get_tags.outputs.version }}_debug/g" module.prop + sed -i "s/versionCode=.*/versionCode=${{ steps.get_tags.outputs.versionCode }}/g" module.prop sh build.sh - name: Release @@ -76,9 +80,9 @@ jobs: COMMIT_MESSAGE: ${{ github.event.head_commit.message }} COMMIT_URL: ${{ github.event.head_commit.url }} RUN_URL: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }} - TITLE: BFM/R ${{ steps.get_tags.outputs.tag }}_${{ steps.get_tags.outputs.date }}_debug + TITLE: B4R ${{ steps.get_tags.outputs.tag }}_${{ steps.get_tags.outputs.version }}_debug run: | - export VERSION=$(date +%m%d) + export VERSION=$(git rev-parse --short HEAD) FILE=$(find ./bfr/* -type f) pip3 install python-telegram-bot python3 docs/tubot.py $FILE \ No newline at end of file diff --git a/box/clash/config.yaml b/box/clash/config.yaml index 051e8f4..2cec33f 100755 --- a/box/clash/config.yaml +++ b/box/clash/config.yaml @@ -229,7 +229,7 @@ proxy-groups: proxy-providers: "provide": type: file - path: ./provide/subscription.yml + path: ./provide/subscription.yaml # filter: 'xxx' # Supports regular expressions to filter by node name # exclude-filter: 'ctb' # Supports regular expressions to exclude based on node name # exclude-type: 'ss|http' # Does not support regular expressions, separated by '|', excluded by node type diff --git a/box/clash/provide/subscription.yml b/box/clash/provide/subscription.yml index ab6c4c2..2c71370 100755 --- a/box/clash/provide/subscription.yml +++ b/box/clash/provide/subscription.yml @@ -1,2 +1,18 @@ proxies: -## add your account \ No newline at end of file + - name: id-rysaputra18n19xz.me + server: 104.18.3.198 + port: 80 + type: vmess + uuid: 46ffa3e3-0f17-4f37-a20a-8fdccd18ce3e + alterId: 0 + cipher: auto + tls: false + skip-cert-verify: true + servername: id-rysaputra18n19xz.me + network: ws + ws-opts: + path: /vmess + headers: + Host: id-rysaputra18n19xz.me + udp: true + xudp: true \ No newline at end of file diff --git a/box/scripts/box.service b/box/scripts/box.service index 1436ff7..ff1398e 100755 --- a/box/scripts/box.service +++ b/box/scripts/box.service @@ -60,6 +60,39 @@ box_run_crontab() { fi } +xclash() { + local xclash_dir="${box_dir}/bin/xclash" + local clash_option="${clash_option:-meta}" # Default to "meta" if clash_option is not set + + if [ -d "$xclash_dir" ]; then + if [ "$clash_option" = "premium" ]; then + if [ -f "${xclash_dir}/clash_premium" ]; then + if ! cp "${xclash_dir}/clash_premium" "${box_dir}/bin/clash"; then + log Error "Failed to use clash_premium" + return 1 + fi + else + log Error "${xclash_dir}/clash_premium file not found" + return 1 + fi + else + if [ -f "${xclash_dir}/clash_meta" ]; then + if ! cp "${xclash_dir}/clash_meta" "${box_dir}/bin/clash"; then + log Error "Failed to use clash_meta" + return 1 + fi + else + log Error "${xclash_dir}/clash_meta file not found" + return 1 + fi + fi + log Info "xclash {{ clash_$clash_option }} setup completed successfully" + else + log Warning "$xclash_dir directory not found" + log Warning "can't use clash_premium/meta option" + fi +} + box_ownership() { # Set ownership and permission of kernel directory chown ${box_user_group} ${bin_path} @@ -312,7 +345,7 @@ temp_clash_config_file() { } box_run_bin() { - log Info "client-list: [ ${bin_list[*]} ]" + log Info "client-list: {{ ${bin_list[*]} }}" log Info "choose: ${bin_name}, start the service." ulimit -SHn 65535 case "${bin_name}" in @@ -529,7 +562,11 @@ start_box() { # Checks if bin_name is defined case "${bin_name}" in - xray|sing-box|clash|v2fly) + clash) + log Info "Good day 🐱" + xclash || exit 1 + ;; + xray|sing-box|v2fly) log Info "Good day 🐱" ;; *) diff --git a/box/scripts/box.tool b/box/scripts/box.tool index c58af70..35a9123 100755 --- a/box/scripts/box.tool +++ b/box/scripts/box.tool @@ -6,12 +6,6 @@ source /data/adb/box/settings.ini # user agent user_agent="box_for_root" -# option to download Clash kernel clash-premium{false} or clash-meta{true} -meta="false" -# for clash-premium -dev=false -# option to download Singbox kernel beta or release -singbox_releases=false # whether use ghproxy to accelerate github download use_ghproxy=true @@ -91,8 +85,8 @@ update_geox() { [ -z "${geodata_mode}" ] && geodata_mode=false case "${bin_name}" in clash) - geoip_file="${box_dir}/clash/$(if [[ "${meta}" == "false" || "${geodata_mode}" == "false" ]]; then echo "Country.mmdb"; else echo "GeoIP.dat"; fi)" - geoip_url="https://github.com/$(if [[ "${meta}" == "false" || "${geodata_mode}" == "false" ]]; then echo "MetaCubeX/meta-rules-dat/raw/release/country-lite.mmdb"; else echo "MetaCubeX/meta-rules-dat/raw/release/geoip-lite.dat"; fi)" + geoip_file="${box_dir}/clash/$(if [[ "${clash_option}" == "premium" || "${geodata_mode}" == "false" ]]; then echo "Country.mmdb"; else echo "GeoIP.dat"; fi)" + geoip_url="https://github.com/$(if [[ "${clash_option}" == "premium" || "${geodata_mode}" == "false" ]]; then echo "MetaCubeX/meta-rules-dat/raw/release/country-lite.mmdb"; else echo "MetaCubeX/meta-rules-dat/raw/release/geoip-lite.dat"; fi)" geosite_file="${box_dir}/clash/GeoSite.dat" geosite_url="https://github.com/MetaCubeX/meta-rules-dat/raw/release/geosite.dat" ;; @@ -269,24 +263,19 @@ update_kernel() { case "${bin_name}" in "sing-box") url_down="https://github.com/SagerNet/sing-box/releases" - if [ "${singbox_releases}" = "false" ]; then - sing_box_version_temp=$(busybox wget --no-check-certificate -qO- "${url_down}" | grep -oE '/tag/v[0-9]+\.[0-9].+-[a-z0-9]+' | head -1 | busybox awk -F'/' '{print $3}' | busybox awk -F'"' '{print $1}') - else - sing_box_version_temp=$(busybox wget --no-check-certificate -qO- "${url_down}" | grep -oE '/tag/v[0-9]+\.[0-9]+\.[0-9]+' | head -1 | busybox awk -F'/' '{print $3}') - fi + sing_box_version_temp=$(busybox wget --no-check-certificate -qO- "${url_down}" | grep -oE '/tag/v[0-9]+\.[0-9]+\.[0-9]+' | head -1 | busybox awk -F'/' '{print $3}') sing_box_version=${sing_box_version_temp#v} download_link="${url_down}/download/${sing_box_version_temp}/sing-box-${sing_box_version}-${platform}-${arch}.tar.gz" log Debug "download ${download_link}" update_file "${box_dir}/${file_kernel}.tar.gz" "${download_link}" && extra_kernel ;; "clash") - if [ "${meta}" = "true" ]; then + if [ "${clash_option}" = "meta" ]; then # set download link and get the latest version download_link="https://github.com/MetaCubeX/Clash.Meta/releases" if [ "$use_ghproxy" == true ]; then download_link="https://ghproxy.com/${download_link}" fi - # tag=$(busybox wget --no-check-certificate -qO- ${download_link} | grep -oE 'tag\/([^"]+)' | cut -d '/' -f 2 | head -1) tag="Prerelease-Alpha" latest_version=$(busybox wget --no-check-certificate -qO- "${download_link}/expanded_assets/${tag}" | grep -oE "alpha-[0-9a-z]+" | head -1) # set the filename based on platform and architecture @@ -296,16 +285,10 @@ update_kernel() { update_file "${box_dir}/${file_kernel}.gz" "${download_link}/download/${tag}/${filename}.gz" && extra_kernel # if meta flag is false, download clash premium/dev else - # if dev flag is true, download latest dev version - if [ "${dev}" != "false" ]; then - log Debug "download https://release.dreamacro.workers.dev/latest/clash-linux-${arch}-latest.gz" - update_file "${box_dir}/${file_kernel}.gz" "https://release.dreamacro.workers.dev/latest/clash-linux-${arch}-latest.gz" && extra_kernel - else # if dev flag is false, download latest premium version - filename=$(busybox wget --no-check-certificate -qO- "https://github.com/Dreamacro/clash/releases/expanded_assets/premium" | grep -oE "clash-linux-${arch}-[0-9]+.[0-9]+.[0-9]+" | head -1) - log Debug "download https://github.com/Dreamacro/clash/releases/download/premium/${filename}.gz" - update_file "${box_dir}/${file_kernel}.gz" "https://github.com/Dreamacro/clash/releases/download/premium/${filename}.gz" && extra_kernel - fi + filename=$(busybox wget --no-check-certificate -qO- "https://github.com/Dreamacro/clash/releases/expanded_assets/premium" | grep -oE "clash-linux-${arch}-[0-9]+.[0-9]+.[0-9]+" | head -1) + log Debug "download https://github.com/Dreamacro/clash/releases/download/premium/${filename}.gz" + update_file "${box_dir}/${file_kernel}.gz" "https://github.com/Dreamacro/clash/releases/download/premium/${filename}.gz" && extra_kernel fi ;; "xray"|"v2fly") @@ -336,13 +319,15 @@ update_kernel() { extra_kernel() { case "${bin_name}" in "clash") - if command -v gunzip >/dev/null 2>&1; then - gunzip_command="gunzip" - else + gunzip_command="gunzip" + if ! command -v gunzip >/dev/null 2>&1; then gunzip_command="busybox gunzip" fi - if ${gunzip_command} "${box_dir}/${file_kernel}.gz" >&2 && - mv "${box_dir}/${file_kernel}" "${bin_dir}/${bin_name}"; then + + if ${gunzip_command} "${box_dir}/${file_kernel}.gz" >&2 && mv "${box_dir}/${file_kernel}" "${bin_dir}/${bin_name}"; then + mkdir -p "${bin_dir}/xclash" + cp "${bin_dir}/${bin_name}" "${bin_dir}/xclash/clash_${clash_option}" + if [ -f "${box_pid}" ]; then restart_box else @@ -353,11 +338,11 @@ extra_kernel() { fi ;; "sing-box") - if command -v tar >/dev/null 2>&1; then - tar_command="tar" - else + tar_command="tar" + if ! command -v tar >/dev/null 2>&1; then tar_command="busybox tar" fi + if ${tar_command} -xf "${box_dir}/${file_kernel}.tar.gz" -C "${box_dir}/bin" >&2 && mv "${box_dir}/bin/sing-box-${sing_box_version}-${platform}-${arch}/sing-box" "${bin_dir}/${bin_name}" && rm -r "${box_dir}/bin/sing-box-${sing_box_version}-${platform}-${arch}"; then @@ -367,7 +352,7 @@ extra_kernel() { log Debug "${bin_name} does not need to be restarted." fi else - log Warning "Failed to extract ${box_dir}/${file_kernel}.tar.gz." + log Error "Failed to extract ${box_dir}/${file_kernel}.tar.gz." fi ;; "v2fly"|"xray") @@ -375,11 +360,11 @@ extra_kernel() { if [ "${bin_name}" != "xray" ]; then bin="v2ray" fi - if command -v unzip >/dev/null 2>&1; then - unzip_command="unzip" - else + unzip_command="unzip" + if ! command -v unzip >/dev/null 2>&1; then unzip_command="busybox unzip" fi + mkdir -p "${bin_dir}/update" if ${unzip_command} -o "${box_dir}/${file_kernel}.zip" "${bin}" -d "${bin_dir}/update" >&2; then if mv "${bin_dir}/update/${bin}" "${bin_dir}/${bin_name}"; then @@ -392,7 +377,7 @@ extra_kernel() { log Error "Failed to move the kernel." fi else - log Warning "Failed to extract ${box_dir}/${file_kernel}.zip." + log Error "Failed to extract ${box_dir}/${file_kernel}.zip." fi rm -rf "${bin_dir}/update" ;; @@ -410,7 +395,7 @@ extra_kernel() { # Check and update yacd update_dashboard() { # su -c /data/adb/box/scripts/box.tool upyacd - if [ "${bin_name}" = "clash" -o "${bin_name}" = "sing-box" ]; then + if [[ "${bin_name}" == @(clash|sing-box) ]]; then file_dashboard="${box_dir}/${bin_name}/dashboard.zip" url="https://github.com/MetaCubeX/Yacd-meta/archive/gh-pages.zip" if [ "$use_ghproxy" == true ]; then diff --git a/box/settings.ini b/box/settings.ini index b68adc8..d4b8ecb 100755 --- a/box/settings.ini +++ b/box/settings.ini @@ -21,6 +21,8 @@ ipv6="false" # list of available kernel binaries bin_list=( "clash" "sing-box" "xray" "v2fly" ) +# for run and download clash_ premium or meta +clash_option="premium" # select the client to use : clash / sing-box / xray / v2fly bin_name="clash" @@ -87,7 +89,7 @@ subscription_url_sing="" name_clash_config="config.yaml" clash_config="${box_dir}/clash/${name_clash_config}" # clash subscription -name_provide_clash_config="subscription.yml" +name_provide_clash_config="subscription.yaml" clash_provide_config="${box_dir}/clash/provide/${name_provide_clash_config}" # sing configuration diff --git a/box/v2fly/config.json b/box/v2fly/config.json index 7fe9b55..6329227 100755 --- a/box/v2fly/config.json +++ b/box/v2fly/config.json @@ -9,7 +9,7 @@ }, "inbounds": [ { - "port": 5335, + "port": 9898, "protocol": "dokodemo-door", "tag": "proxy-in", "settings": { diff --git a/box/xray/config.json b/box/xray/config.json index 78b7bbb..0a7348f 100755 --- a/box/xray/config.json +++ b/box/xray/config.json @@ -9,7 +9,7 @@ }, "inbounds": [ { - "port": 5335, + "port": 9898, "protocol": "dokodemo-door", "tag": "proxy-in", "settings": { diff --git a/customize.sh b/customize.sh index 2f7e52a..89fa108 100755 --- a/customize.sh +++ b/customize.sh @@ -57,6 +57,7 @@ fi ui_print "- Create directories" mkdir -p $MODPATH/system/bin/ mkdir -p /data/adb/box/run/ +mkdir -p /data/adb/box/bin/xclash/ ui_print "- Extract the files uninstall.sh and box_service.sh into the $MODPATH folder and ${service_dir}" unzip -j -o "$ZIPFILE" 'uninstall.sh' -d "$MODPATH" >&2