#!/sbin/openrc-run

description="Powerful, lightning-fast, censorship-resistant proxy"
command=/usr/bin/hysteria
command_args="client --disable-update-check ${command_args:-}"
: ${command_user:=hysteria:hysteria}
: ${cfgfile:="/etc/hysteria.yaml"}

output_logger="logger -t hysteria -p daemon.info"
error_logger="logger -t hysteria -p daemon.info"

capabilities="^cap_net_admin ^cap_net_raw"
no_new_privs="yes"
supervisor="supervise-daemon"

depend() {
	need net
	after firewall
}

checkconfig() {
	if [ ! -e "${cfgfile}" ]; then
		eerror "$cfgfile does not exist."
		return 1
	fi
}

start_pre() {
	checkconfig
        eend $?
}
