commit f26531c
merc
·
2026-08-01 02:03:49 +0000 UTC
parent a029994
refactor: use config.json directly and update man page accordingly (fucking finally)
M
bs
+5,
-5
1@@ -22,8 +22,8 @@ case "$1" in
2 done
3 ;;
4 -C|--current)
5- if [ -L /etc/sing-box/active.json ] && [ -e /etc/sing-box/active.json ]; then
6- l=$(readlink /etc/sing-box/active.json)
7+ if [ -L /etc/sing-box/config.json ] && [ -e /etc/sing-box/config.json ]; then
8+ l=$(readlink /etc/sing-box/config.json)
9 n=$(basename "$l" .json)
10 p=$(jq -r '.outbounds[] | select(.type != "direct") | .type' "$l")
11 [ -z "$p" ] && p="unknown"
12@@ -45,7 +45,7 @@ case "$1" in
13 exit 1
14 fi
15 rc-service "$serviceNm" stop
16- rm -f /etc/sing-box/active.json
17+ rm -f /etc/sing-box/config.json
18 ;;
19 -*)
20 echo "invalid option $1"
21@@ -67,7 +67,7 @@ case "$1" in
22 for f in /etc/sing-box/list/*.json; do
23 [ -f "$f" ] || continue
24 if [ "$i" -eq "$1" ]; then
25- ln -sf "/etc/sing-box/list/$(basename "$f")" /etc/sing-box/active.json
26+ ln -sf "/etc/sing-box/list/$(basename "$f")" /etc/sing-box/config.json
27 rc-service "$serviceNm" restart
28 exit 0
29 fi
30@@ -82,7 +82,7 @@ case "$1" in
31 exit 1
32 fi
33
34- ln -sf "/etc/sing-box/list/$1.json" /etc/sing-box/active.json
35+ ln -sf "/etc/sing-box/list/$1.json" /etc/sing-box/config.json
36 rc-service "$serviceNm" restart
37 ;;
38 esac
M
bs.1
+1,
-15
1@@ -19,7 +19,7 @@ switches between .json configs from
2 .Pa /etc/sing-box/list/
3 .Pp
4 the selected config is symlinked to
5-.Pa /etc/sing-box/active.json
6+.Pa /etc/sing-box/config.json
7 .Pp
8 the
9 .Em sing-box-openrc
10@@ -28,20 +28,6 @@ package on Alpine should provide the required service. if not, write your own.
11 this was written for
12 .Em OpenRC ,
13 so no other init systems are supported. you're free to change this script locally as you wish.
14-.Pp
15-important info! i modified
16-.Em /etc/init.d/sing-box
17-(specifically ln.10) to use
18-.Em /etc/sing-box/active.json
19-by default instead of
20-.Em config.json .
21-thinking back, i could've just made
22-.Nm bs
23-use
24-.Em config.json
25-instead of
26-.Em active.json
27-so no one has to modify the service itself... but whatever now.
28 .Sh SEE ALSO
29 .Xr rc-service 8 ,
30 .Xr ln 1 ,