aboutsummaryrefslogtreecommitdiff
path: root/net/sing-box/files
diff options
context:
space:
mode:
authorVan Waholtz <brvphoenix@gmail.com>2022-12-12 21:59:43 +0800
committerTianling Shen <cnsztl@gmail.com>2023-02-10 08:45:15 +0800
commitc85a23a81eac541c03ed9af78e282d660ecbeae1 (patch)
treef33a45e82c0b95047cbeadb04bb7c4464c262c48 /net/sing-box/files
parent4947b057cfc8e593c47cac06889707f89aff08cd (diff)
sing-box: add new package
Signed-off-by: Van Waholtz <brvphoenix@gmail.com>
Diffstat (limited to 'net/sing-box/files')
-rw-r--r--net/sing-box/files/sing-box.conf7
-rwxr-xr-xnet/sing-box/files/sing-box.init39
2 files changed, 46 insertions, 0 deletions
diff --git a/net/sing-box/files/sing-box.conf b/net/sing-box/files/sing-box.conf
new file mode 100644
index 000000000..c776790e8
--- /dev/null
+++ b/net/sing-box/files/sing-box.conf
@@ -0,0 +1,7 @@
+
+config sing-box 'main'
+ option enabled '0'
+ option user 'sing-box'
+ option conffile '/etc/sing-box/config.json'
+ option workdir '/usr/share/sing-box'
+
diff --git a/net/sing-box/files/sing-box.init b/net/sing-box/files/sing-box.init
new file mode 100755
index 000000000..277c9f2ee
--- /dev/null
+++ b/net/sing-box/files/sing-box.init
@@ -0,0 +1,39 @@
+#!/bin/sh /etc/rc.common
+
+USE_PROCD=1
+START=99
+
+NAME="sing-box"
+PROG="/usr/bin/sing-box"
+
+start_service() {
+ config_load "$NAME"
+
+ local enabled user group conffile workdir
+ config_get_bool enabled "main" "enabled" "0"
+ [ "$enabled" -eq "1" ] || return 0
+
+ config_get user "main" "user" "root"
+ config_get conffile "main" "conffile"
+ config_get workdir "main" "workdir" "/usr/share/sing-box"
+
+ mkdir -p "$workdir"
+ local group="$(id -ng $user)"
+ chown $user:$group "$workdir"
+
+ procd_open_instance "$NAME.main"
+ procd_set_param command "$PROG" run -c "$conffile" -D "$workdir"
+
+ # Use root user if you want to use the TUN mode.
+ procd_set_param user "$user"
+ procd_set_param file "$conffile"
+ procd_set_param stdout 1
+ procd_set_param stderr 1
+ procd_set_param respawn
+
+ procd_close_instance
+}
+
+service_triggers() {
+ procd_add_reload_trigger "$NAME"
+}