#!/bin/sh

# PROVIDE: shadowsocks-libev
# REQUIRE: LOGIN cleanvar
# KEYWORD: shutdown

# Add the following lines to /etc/rc.conf to enable shadowsocks-libev:
# shadowsocks_libev_enable (bool):  Set to "NO" by default.
#      Set to "YES" to enable shadowsocks-libev.
# shadowsocks_libev_config (path): Shadowsocks config file.
#      Defaults to "%%PREFIX%%/etc/shadowsocks-libev/config.json"


. /etc/rc.subr

name="shadowsocks_libev"
rcvar=shadowsocks_libev_enable


load_rc_config $name

: ${shadowsocks_libev_enable:="NO"}
: ${shadowsocks_libev_config="%%PREFIX%%/etc/shadowsocks-libev/config.json"}

command="%%PREFIX%%/bin/ss-server" 
pidfile="/var/run/shadowsocks-libev.pid"
required_files="${shadowsocks_libev_config}"

command_args="-f $pidfile -c $shadowsocks_libev_config"

run_rc_command "$1"
