mirror of
https://github.com/beard7n/bsdports.git
synced 2026-04-10 02:21:15 +02:00
48 lines
1.4 KiB
Bash
48 lines
1.4 KiB
Bash
#!/bin/sh
|
|
|
|
# PROVIDE: xray
|
|
# REQUIRE: LOGIN
|
|
# KEYWORD: shutdown
|
|
|
|
# Add these lines to /etc/rc.conf.local or /etc/rc.conf to enable `xray':
|
|
#
|
|
# xray_enable (bool): Set to "NO" by default.
|
|
# Set it to "YES" to enable xray
|
|
# xray_config (path): Set to "%%PREFIX%%/etc/xray/config.json" by default
|
|
# Set it to the xray server config
|
|
# xray_logdir (path): Set to "/var/log/xray" by default.
|
|
# Set it to the directory of xray log files
|
|
# xray_env (str): Set to "" by default.
|
|
# Set it to the desired environment variables
|
|
|
|
. /etc/rc.subr
|
|
|
|
name="xray"
|
|
rcvar="${name}_enable"
|
|
|
|
: ${xray_enable="NO"}
|
|
: ${xray_config="%%PREFIX%%/etc/$name/config.json"}
|
|
: ${xray_logdir="/var/log/${name}"}
|
|
: ${xray_env=""}
|
|
: ${xray_user="%%USER%%"}
|
|
: ${xray_group="%%GROUP%%"}
|
|
|
|
asset_env="XRAY_LOCATION_ASSET=%%PREFIX%%/share/$name"
|
|
pidfile="/var/run/$name.pid"
|
|
procname="%%PREFIX%%/bin/$name"
|
|
command="/usr/sbin/daemon"
|
|
command_args="-c -p ${pidfile} /usr/bin/env ${asset_env} ${xray_env} ${procname} -config ${xray_config}"
|
|
required_files="${xray_config}"
|
|
|
|
start_precmd="xray_startprecmd"
|
|
|
|
xray_startprecmd() {
|
|
touch "${pidfile}"
|
|
chown ${xray_user}:${xray_group} "${pidfile}"
|
|
mkdir -p "${xray_logdir}"
|
|
chown -R ${xray_user}:${xray_group} "${xray_logdir}"
|
|
}
|
|
|
|
load_rc_config "$name"
|
|
run_rc_command "$1"
|