From c85a23a81eac541c03ed9af78e282d660ecbeae1 Mon Sep 17 00:00:00 2001 From: Van Waholtz Date: Mon, 12 Dec 2022 21:59:43 +0800 Subject: sing-box: add new package Signed-off-by: Van Waholtz --- net/sing-box/files/sing-box.conf | 7 +++++++ net/sing-box/files/sing-box.init | 39 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 46 insertions(+) create mode 100644 net/sing-box/files/sing-box.conf create mode 100755 net/sing-box/files/sing-box.init (limited to 'net/sing-box/files') 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" +} -- cgit v1.2.3