Skip to content

Commit

Permalink
adjust: busybox check
Browse files Browse the repository at this point in the history
  • Loading branch information
tearmoon committed Dec 23, 2023
1 parent af913f1 commit c798850
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 13 deletions.
21 changes: 10 additions & 11 deletions box/scripts/box.service
Original file line number Diff line number Diff line change
Expand Up @@ -156,10 +156,11 @@ prepare_singbox() {
fi

# delete Toggle comment, because yq doesn't work, Execute the sed command to uncomment the "/* ... */", "//" line
# sed -i '/\/\*/,/\*\//d; /^[[:space:]]*\/\//d; /^( *\/\/|\/\*.*\*\/)$/d'
# sed -i '/\/\*/,/\*\//d; /^[[:space:]]*\/\//d; /^( *\/\/|\/\*.*\*\/)$/d' "${box_dir}/sing-box/"*.json

# format sing-box configuration
if ${bin_path} format -w -D "${box_dir}/${bin_name}" -C "${box_dir}/${bin_name}" > "${box_run}/${bin_name}.log" 2>&1; then
# if sed -i '/\/\*/,/\*\//d; /^[[:space:]]*\/\//d; /^( *\/\/|\/\*.*\*\/)$/d' "${box_dir}/sing-box/"*.json 2>&1; then
if [[ "${network_mode}" == "mixed" || "${proxy_mode}" == "tun" ]]; then
if grep -q '"type": "tproxy"' "${sing_config}"; then
"${yq_command}" 'del(.inbounds[] | select(.type == "tproxy"))' -i --output-format=json "${sing_config}"
Expand Down Expand Up @@ -520,14 +521,6 @@ start_box() {
echo -n "" > "${box_log}"
box_version=$(busybox awk '!/^ *#/ && /version=/ { print $0 }' "/data/adb/modules/box_for_root/module.prop" 2>/dev/null)

# busybox check
busybox_code=$(busybox | head -n 1 | busybox awk '{print $2}' | sed -e 's/^v//' -e 's/-osm0sis$//' -e 's/-Magisk$//')
if [ "$(echo "${busybox_code}" | busybox awk -F. '{printf "%03d%03d%03d\n", $1, $2, $3}')" -lt "$(echo "1.36.1" | busybox awk -F. '{printf "%03d%03d%03d\n", $1, $2, $3}')" ]; then
log Info "Current busybox v${busybox_code}"
log Error "Please update your busybox to version 1.36.1+ latest"
exit 1
fi

if [ -t 1 ]; then
echo -e "${yellow}$(getprop persist.sys.timezone)${normal}"
echo -e "${yellow}$(getprop gsm.sim.operator.alpha) / $(getprop gsm.network.type)${normal}"
Expand Down Expand Up @@ -580,8 +573,14 @@ start_box() {
;;
esac

# show the current version of busybox
log Info "Current busybox v${busybox_code}"
# busybox check
busybox_code=$(busybox | head -n 1 | busybox awk '{print $2}' | sed -e 's/^v//' -e 's/-osm0sis$//' -e 's/-Magisk$//')
if [ "$(echo "${busybox_code}" | busybox awk -F. '{printf "%03d%03d%03d\n", $1, $2, $3}')" -lt "$(echo "1.36.1" | busybox awk -F. '{printf "%03d%03d%03d\n", $1, $2, $3}')" ]; then
log Info "Current $(which busybox) v${busybox_code}"
log Warning "Please update your busybox to v1.36.1+"
else
log Info "Current $(which busybox) v${busybox_code}"
fi

# Check permissions, check for bin existence, delete old logs, create a TUN if necessary, run box, and wait for 1 second
box_permission
Expand Down
4 changes: 2 additions & 2 deletions box/settings.ini
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/system/bin/sh

if [ ! -d /data/adb/modules/busybox-ndk ]; then
export PATH="/data/adb/magisk:/data/adb/ksu/bin:$PATH:/system/bin"
if [ ! -f /system/bin/busybox ]; then
export PATH="/data/adb/magisk:/data/adb/ksu/bin:$PATH:/system/bin"
fi

# Take the current time
Expand Down

0 comments on commit c798850

Please sign in to comment.