Skip to content

Commit

Permalink
kernelsu添加clash面板 (#106)
Browse files Browse the repository at this point in the history
* kernelsu添加clash面板

* 删除无用目录

* 判断为clash核心时则为kernelsu添加webui面板

---------

Co-authored-by: Your Name <[email protected]>
  • Loading branch information
2 people authored and twnesss committed Mar 28, 2024
1 parent 0a3632b commit 427fcd0
Show file tree
Hide file tree
Showing 5 changed files with 58 additions and 8 deletions.
4 changes: 4 additions & 0 deletions box/scripts/box.service
Original file line number Diff line number Diff line change
Expand Up @@ -685,6 +685,10 @@ if ! command -v busybox &> /dev/null; then
exit 1
fi

if command -v ksud &>/dev/null; then
$scripts_dir/box.tool webroot >/dev/null 2>&1
fi

case "$1" in
start)
stop_box >> /dev/null 2>&1
Expand Down
46 changes: 44 additions & 2 deletions box/scripts/box.tool
Original file line number Diff line number Diff line change
Expand Up @@ -630,9 +630,48 @@ cgroup_cpuset() {
return 0
}

ip_port=$(if [ "${bin_name}" = "clash" ]; then busybox awk '/external-controller:/ {print $2}' "${clash_config}"; else find /data/adb/box/sing-box/ -maxdepth 1 -type f -name "*.json" -exec busybox awk -F':' '/experimental/,/\}/' {} \; | sed -n 's/.*"external_controller": "\(.*\)",/\1/p'; fi;)
ip_port=$(if [ "${bin_name}" = "clash" ]; then busybox awk '/external-controller:/ {print $2}' "${clash_config}"; else find /data/adb/box/sing-box/ -type f -name 'config.json' -exec busybox awk -F'[:,]' '/external_controller/ {print $2":"$3}' {} \; | sed 's/^[ \t]*//;s/"//g'; fi;)
secret=""

webroot() {
path_webroot="/data/adb/modules/box_for_root/webroot/index.html"
touch -n > $path_webroot
if [[ "${bin_name}" = @(clash|sing-box) ]]; then
echo -e '
<!DOCTYPE html>
<script>
document.location = 'http://127.0.0.1:9090/ui/'
</script>
</html>
' > $path_webroot
sed -i "s#document\.location =.*#document.location = 'http://$ip_port/ui/'#" $path_webroot
else
echo -e '
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Unsupported Dashboard</title>
<style>
body {
font-family: Arial, sans-serif;
text-align: center;
padding: 50px;
}
h1 {
color: red;
}
</style>
</head>
<body>
<h1>Unsupported Dashboard</h1>
<p>Sorry, xray/v2ray does not support the necessary Dashboard features.</p>
</body>
</html>' > $path_webroot
fi
}

bond1() {
su -mm -c "cmd wifi force-low-latency-mode enabled"
su -mm -c "sysctl -w net.ipv4.tcp_low_latency=1"
Expand Down Expand Up @@ -699,6 +738,9 @@ case "$1" in
reload)
reload
;;
webroot)
webroot
;;
all)
upyq
upcurl
Expand All @@ -711,6 +753,6 @@ case "$1" in
;;
*)
echo "${red}$0 $1 no found${normal}"
echo "${yellow}usage${normal}: ${green}$0${normal} {${yellow}check|memcg|cpuset|blkio|geosub|geox|subs|upkernel|upxui|upyq|upcurl|reload|bond0|bond1|all${normal}}"
echo "${yellow}usage${normal}: ${green}$0${normal} {${yellow}check|memcg|cpuset|blkio|geosub|geox|subs|upkernel|upxui|upyq|upcurl|reload|webroot|bond0|bond1|all${normal}}"
;;
esac
2 changes: 1 addition & 1 deletion box/settings.ini
Original file line number Diff line number Diff line change
Expand Up @@ -148,4 +148,4 @@ log() {
notify "box_for_root" "${message}"
fi

}
}
9 changes: 4 additions & 5 deletions customize.sh
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ if [ -d "/data/adb/modules/box_for_magisk" ]; then
fi

ui_print "- Installing Box for Magisk/KernelSU/APatch"
unzip -o "$ZIPFILE" -x 'META-INF/*' -d "$MODPATH" >&2
unzip -o "$ZIPFILE" -x 'META-INF/*' -x 'webroot/*' -d "$MODPATH" >&2

if [ -d "/data/adb/box" ]; then
ui_print "- Backup box"
Expand All @@ -57,7 +57,6 @@ else
fi

ui_print "- Create directories"
mkdir -p $MODPATH/system/bin/
mkdir -p /data/adb/box/
mkdir -p /data/adb/box/run/
mkdir -p /data/adb/box/bin/xclash/
Expand All @@ -71,11 +70,12 @@ set_perm_recursive $MODPATH 0 0 0755 0644
set_perm_recursive /data/adb/box/ 0 3005 0755 0644
set_perm_recursive /data/adb/box/scripts/ 0 3005 0755 0700
set_perm ${service_dir}/box_service.sh 0 0 0755
set_perm $MODPATH/service.sh 0 0 0755
set_perm $MODPATH/uninstall.sh 0 0 0755
set_perm /data/adb/box/scripts/ 0 0 0755

# fix "set_perm_recursive /data/adb/box/scripts" not working on some phones.
chmod ugo+x ${service_dir}/box_service.sh
chmod ugo+x $MODPATH/uninstall.sh
chmod ugo+x /data/adb/box/scripts/*

ui_print "-----------------------------------------------------------"
Expand All @@ -90,8 +90,6 @@ while true ; do
timeout 1 getevent -lc 1 2>&1 | grep KEY_VOLUME > "$TMPDIR/events"
if [ $(( NOW_TIME - START_TIME )) -gt 9 ] ; then
ui_print "- No input detected after 10 seconds"
# ui_print "- Downloading Kernel Anyway...."
# /data/adb/box/scripts/box.tool all
break
else
if $(cat $TMPDIR/events | grep -q KEY_VOLUMEUP) ; then
Expand Down Expand Up @@ -145,6 +143,7 @@ fi

if [ "$KSU" = "true" ]; then
sed -i "s/name=.*/name=Box for KernelSU/g" $MODPATH/module.prop
unzip -o "$ZIPFILE" 'webroot/*' -d "$MODPATH" >&2
elif [ "$APATCH" = "true" ]; then
sed -i "s/name=.*/name=Box for APatch/g" $MODPATH/module.prop
else
Expand Down
5 changes: 5 additions & 0 deletions webroot/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<!DOCTYPE html>
<script>
document.location = 'http://127.0.0.1:9090/ui/'
</script>
</html>

0 comments on commit 427fcd0

Please sign in to comment.