diff --git a/net/wireproxy/Makefile b/net/wireproxy/Makefile index 1706f944e07d..8e14d5f212a5 100644 --- a/net/wireproxy/Makefile +++ b/net/wireproxy/Makefile @@ -1,21 +1,23 @@ PORTNAME= wireproxy DISTVERSIONPREFIX= v DISTVERSION= 1.0.9 -PORTREVISION= 18 +PORTREVISION= 19 CATEGORIES= net MAINTAINER= lwhsu@FreeBSD.org COMMENT= Wireguard client that exposes itself as a socks5 proxy WWW= https://github.com/pufferffish/wireproxy LICENSE= ISCL LICENSE_FILE= ${WRKSRC}/LICENSE USES= go:modules GO_MODULE= github.com/pufferffish/wireproxy GO_TARGET= ./cmd/wireproxy +USE_RC_SUBR= wireproxy + PLIST_FILES= bin/wireproxy .include diff --git a/net/wireproxy/files/wireproxy.in b/net/wireproxy/files/wireproxy.in new file mode 100644 index 000000000000..019337445fd5 --- /dev/null +++ b/net/wireproxy/files/wireproxy.in @@ -0,0 +1,64 @@ +#!/bin/sh + +# PROVIDE: wireproxy +# REQUIRE: LOGIN NETWORKING +# KEYWORD: shutdown + +# Add the following lines to /etc/rc.conf to enable wireproxy: +# wireproxy_enable (bool): Set to "NO" by default. +# Set it to "YES" to enable wireproxy. +# wireproxy_checkconfig (bool): Set to "YES" by default. +# Set it to "YES" to check configuration when starting. +# wireproxy_configfile (str): Set to "%%PREFIX%%/etc/wireproxy.conf" by default. +# Path to configuration file. +# wireproxy_logfile (str): Set to "/var/log/wireproxy.log" by default. +# Path to log file. +# wireproxy_user (str): Set to "nobody" by default. +# User to run wireproxy. +# wireproxy_flags (str): Set to "" by default. +# Extra flags passed to start command. + +. /etc/rc.subr + +name=wireproxy +rcvar=wireproxy_enable +desc="WireGuard client that exposes itself as a SOCKS5/HTTP proxy" + +load_rc_config ${name} + +: ${wireproxy_enable:=NO} +: ${wireproxy_checkconfig=YES} +: ${wireproxy_configfile="%%PREFIX%%/etc/wireproxy.conf"} +: ${wireproxy_logfile=/var/log/wireproxy.log} +: ${wireproxy_user=nobody} + +procname="%%PREFIX%%/bin/wireproxy" +pidfile="/var/run/${name}.pid" +daemonpidfile="/var/run/daemon_${name}.pid" +required_files="${wireproxy_configfile}" +command=/usr/sbin/daemon +command_args="-f -H -o ${wireproxy_logfile} -p ${pidfile} -P ${daemonpidfile} ${procname} -c ${wireproxy_configfile}" + +start_precmd="${name}_precmd" +stop_postcmd="rm -f ${pidfile} ${daemonpidfile}" +configtest_cmd="${name}_configtest" +extra_commands=configtest + +wireproxy_precmd() +{ + /usr/bin/install -m 600 -o ${wireproxy_user} /dev/null ${pidfile} + /usr/bin/install -m 600 -o ${wireproxy_user} /dev/null ${daemonpidfile} + /usr/bin/install -m 640 -o ${wireproxy_user} /dev/null ${wireproxy_logfile} + + if checkyesno wireproxy_checkconfig; then + wireproxy_configtest + fi +} + +wireproxy_configtest() +{ + echo "Performing sanity check on ${name} configuration:" + ${procname} --configtest --config ${wireproxy_configfile} +} + +run_rc_command "$1"