Skip to content

Commit

Permalink
Adapting the Scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
taamarin authored and shioeri committed Jul 3, 2023
1 parent 767a954 commit e6516c8
Show file tree
Hide file tree
Showing 7 changed files with 613 additions and 576 deletions.
2 changes: 1 addition & 1 deletion box/scripts/box.inotify
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ service_path="/data/adb/box/scripts/box.service"
iptables_path="/data/adb/box/scripts/box.iptables"
data_box="/data/adb/box"
run_path="/data/adb/box/run"
now=$(date +"%R")
now=$(date +"%I:%M %p")

events=$1
monitor_dir=$2
Expand Down
264 changes: 140 additions & 124 deletions box/scripts/box.iptables

Large diffs are not rendered by default.

464 changes: 245 additions & 219 deletions box/scripts/box.service

Large diffs are not rendered by default.

391 changes: 186 additions & 205 deletions box/scripts/box.tool

Large diffs are not rendered by default.

27 changes: 20 additions & 7 deletions box/scripts/start.sh
Original file line number Diff line number Diff line change
Expand Up @@ -21,24 +21,37 @@ refresh_box() {
}

start_service() {
if [ ! -f "/data/adb/box/manual" ]; then
if [ ! -f "${moddir}/disable" ]; then
"${scripts_dir}/box.service" start >> "/dev/null" 2>&1
fi
}

enable_iptables() {
PIDS=("clash" "xray" "sing-box" "v2fly")
PID=""
i=0
while [ -z "$PID" ] && [ "$i" -lt "${#PIDS[@]}" ]; do
PID=$(${busybox} pidof "${PIDS[$i]}")
i=$((i+1))
done

if [ -f "/data/adb/box/run/box.pid" ]; then
if [ -n "$PID" ]; then
"${scripts_dir}/box.iptables" enable >> "/dev/null" 2>&1
fi
}

for pid in $(pidof inotifyd); do
if grep -q box.inotify /proc/${pid}/cmdline; then
start_inotifyd() {
for PID in $(${busybox} pidof inotifyd); do
if grep -q box.inotify /proc/$PID/cmdline; then
kill -15 ${pid}
fi
done
sleep 0.3
inotifyd "${scripts_dir}/box.inotify" "${moddir}" >> "/dev/null" 2>&1 &
fi
}

refresh_box
start_service
if [ ! -f "/data/adb/box/manual" ]; then
start_service
enable_iptables
start_inotifyd
fi
39 changes: 20 additions & 19 deletions box/settings.ini
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@

export PATH="/data/adb/magisk:/data/adb/ksu/bin:$PATH:/system/bin"

# Take the current time
now=$(date +"%I:%M %p")

# define the settings and paths
settings="/data/adb/box/settings.ini"

Expand Down Expand Up @@ -44,7 +47,7 @@ ignore_out_list=()

# Set cgroup to limit memory usage
cgroup_memory="false"
cgroup_memory_limit="50M"
cgroup_memory_limit="20M"
cgroup_memory_path=""

# Set box directory variables
Expand Down Expand Up @@ -101,24 +104,22 @@ white="\033[1;37"
gray="\033[1;90m"

log() {
# Take the current time
now=$(date +"%I:%M %p")
# Selects the text color according to the parameters
case $1 in
info) color="${blue}" ;;
error) color="${red}" ;;
warn) color="${yellow}" ;;
*) color="${green}" ;;
esac
# Add messages to time and parameters
message="${now} [$1]: $2"
if [ -t 1 ]; then
# Prints messages to the console
echo -e "${color}${message}${normal}"
else
# Print messages to a log file
echo "${message}" >> ${box_log} 2>&1
fi
# Selects the text color according to the parameters
case $1 in
info) color="${blue}" ;;
error) color="${red}" ;;
warn) color="${yellow}" ;;
*) color="${green}" ;;
esac
# Add messages to time and parameters
message="${now} [$1]: $2"
if [ -t 1 ]; then
# Prints messages to the console
echo -e "${color}${message}${normal}"
else
# Print messages to a log file
echo "${message}" >> ${box_log} 2>&1
fi
}

# open yacd on start
Expand Down
2 changes: 1 addition & 1 deletion box/sing-box/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@
"clash_api": {
"external_controller": "127.0.0.1:9090",
"external_ui": "./dashboard",
"store_selected": false
"store_selected": true
}
}
}

0 comments on commit e6516c8

Please sign in to comment.