V2ray-core: 求一个freebsd或者openbsd下的v2ray启动脚本

Created on 21 May 2018  ·  3Comments  ·  Source: v2ray/v2ray-core

同题,求一个freebsd或者openbsd下开机自动运行v2ray的脚本,就是可以servcie v2ray start 那种

Most helpful comment

脚本名为v2ray,内容请见文末,赋555权限,放在 /usr/local/etc/rc.d/ ,在 /etc/rc.conf 里加上 v2ray_enable="YES" 可以开机启动。
v2ray-freebsd-64.zip 解开后,将目录 v2ray-v{version}-freebsd-64 改名为 v2ray-current 放到 /usr/local/ ,配置文件放在 /usr/local/etc/v2ray_config.json 。
出于安全考虑,服务会跑在www用户下,如果有日志需求,请将日志目录的 owner 改为 www:www

相关目录结构:
/usr/local/v2ray-current
/usr/local/v2ray-current/geoip.dat
/usr/local/v2ray-current/geosite.dat
/usr/local/v2ray-current/readme.md
/usr/local/v2ray-current/v2ctl
/usr/local/v2ray-current/v2ctl.sig
/usr/local/v2ray-current/v2ray
/usr/local/v2ray-current/v2ray.sig
/usr/local/v2ray-current/vpoint_socks_vmess.json
/usr/local/v2ray-current/vpoint_vmess_freedom.json
/usr/local/etc/v2ray_config.json
/usr/local/etc/rc.d/v2ray

脚本内容:

#!/bin/sh

# PROVIDE: v2ray
# REQUIRE: netif NETWORKING ipmon ipfw netwait
# BEFORE: LOGIN
# KEYWORD:

. /etc/rc.subr

name="v2ray"
rcvar=v2ray_enable

start_precmd="v2ray_checkconfig"
restart_precmd="v2ray_checkconfig"
reload_precmd="v2ray_checkconfig"
configtest_cmd="v2ray_checkconfig"
command="/usr/local/v2ray-current/v2ray"
command_args="&"
required_files=/usr/local/etc/${name}_config.json
extra_commands="reload configtest"
v2ray_user=www
v2ray_group=www

load_rc_config "v2ray"

v2ray_configfile="/usr/local/etc/v2ray_config.json"
v2ray_flags="-config ${v2ray_configfile}"

v2ray_checkconfig()
{
 eval ${command} ${v2ray_flags} -test
}

run_rc_command "$1"

All 3 comments

欢迎PR,暂时没有计划支持非Linux系统的安装脚本。

Nooooooooooooo!

Kinda like BSD system.

脚本名为v2ray,内容请见文末,赋555权限,放在 /usr/local/etc/rc.d/ ,在 /etc/rc.conf 里加上 v2ray_enable="YES" 可以开机启动。
v2ray-freebsd-64.zip 解开后,将目录 v2ray-v{version}-freebsd-64 改名为 v2ray-current 放到 /usr/local/ ,配置文件放在 /usr/local/etc/v2ray_config.json 。
出于安全考虑,服务会跑在www用户下,如果有日志需求,请将日志目录的 owner 改为 www:www

相关目录结构:
/usr/local/v2ray-current
/usr/local/v2ray-current/geoip.dat
/usr/local/v2ray-current/geosite.dat
/usr/local/v2ray-current/readme.md
/usr/local/v2ray-current/v2ctl
/usr/local/v2ray-current/v2ctl.sig
/usr/local/v2ray-current/v2ray
/usr/local/v2ray-current/v2ray.sig
/usr/local/v2ray-current/vpoint_socks_vmess.json
/usr/local/v2ray-current/vpoint_vmess_freedom.json
/usr/local/etc/v2ray_config.json
/usr/local/etc/rc.d/v2ray

脚本内容:

#!/bin/sh

# PROVIDE: v2ray
# REQUIRE: netif NETWORKING ipmon ipfw netwait
# BEFORE: LOGIN
# KEYWORD:

. /etc/rc.subr

name="v2ray"
rcvar=v2ray_enable

start_precmd="v2ray_checkconfig"
restart_precmd="v2ray_checkconfig"
reload_precmd="v2ray_checkconfig"
configtest_cmd="v2ray_checkconfig"
command="/usr/local/v2ray-current/v2ray"
command_args="&"
required_files=/usr/local/etc/${name}_config.json
extra_commands="reload configtest"
v2ray_user=www
v2ray_group=www

load_rc_config "v2ray"

v2ray_configfile="/usr/local/etc/v2ray_config.json"
v2ray_flags="-config ${v2ray_configfile}"

v2ray_checkconfig()
{
 eval ${command} ${v2ray_flags} -test
}

run_rc_command "$1"

Was this page helpful?
0 / 5 - 0 ratings

Related issues

supersonic600 picture supersonic600  ·  3Comments

ghost picture ghost  ·  4Comments

nielspeen picture nielspeen  ·  4Comments

vonhezhou picture vonhezhou  ·  4Comments

TheWanderingCoel picture TheWanderingCoel  ·  3Comments