Skip to content

Commit

Permalink
net/microsocks: Add rc script
Browse files Browse the repository at this point in the history
- Bump PORTREVISION for package change

PR:		253284
Reported by:	Pavel Timofeev <timp87@gmail.com>
  • Loading branch information
sunpoet committed Feb 28, 2022
1 parent 8699685 commit 28cb794
Show file tree
Hide file tree
Showing 2 changed files with 67 additions and 0 deletions.
3 changes: 3 additions & 0 deletions net/microsocks/Makefile
@@ -1,5 +1,6 @@
PORTNAME= microsocks
PORTVERSION= 1.0.2
PORTREVISION= 1
CATEGORIES= net
MASTER_SITES= https://ftp.barfooze.de/pub/sabotage/tarballs/

Expand All @@ -11,6 +12,8 @@ LICENSE_FILE= ${WRKSRC}/COPYING

USES= tar:xz

USE_RC_SUBR= microsocks

PLIST_FILES= bin/microsocks

do-install:
Expand Down
64 changes: 64 additions & 0 deletions net/microsocks/files/microsocks.in
@@ -0,0 +1,64 @@
#!/bin/sh

# PROVIDE: microsocks
# REQUIRE: LOGIN
# KEYWORD: shutdown

# Add these lines to /etc/rc.conf.local or /etc/rc.conf
# to enable this service:
#
# microsocks_enable (bool): Enable microsocks
# Default: NO
# microsocks_user (str): User to run microsocks under
# Default: unset
# microsocks_args (str): Arguments for microsocks
# Default: unset
# microsocks_syslog_enable(bool): Enable writing output to syslog.
# Default: YES
# microsocks_syslog_tag(str): Syslog tag if syslog enabled.
# Default: microsocks
# microsocks_syslog_priority(str): Syslog priority if syslog enabled.
# Default: info
# microsocks_syslog_facility(str): Syslog facility if syslog enabled.
# Default: daemon

. /etc/rc.subr

name=microsocks
rcvar=microsocks_enable

load_rc_config $name

: ${microsocks_enable:="NO"}
: ${microsocks_syslog_enable:="YES"}
: ${microsocks_syslog_facility:="daemon"}
: ${microsocks_syslog_priority:="info"}
: ${microsocks_syslog_tag:="microsocks"}
: ${microsocks_syslog_flags:=""}

start_precmd=microsocks_prestart
stop_postcmd=microsocks_poststop

if checkyesno microsocks_syslog_enable; then
microsocks_syslog_flags="-T ${microsocks_syslog_tag} -s ${microsocks_syslog_priority} -l ${microsocks_syslog_facility}"
fi

pidfile="/var/run/${name}.pid"
microsocks_command="%%PREFIX%%/bin/${name}"
command="/usr/sbin/daemon"
command_args="-f ${microsocks_syslog_flags} -P ${pidfile} -t ${name} ${microsocks_command} ${microsocks_args}"

microsocks_prestart()
{
if [ -z "${microsocks_user}" ]; then
err 3 "microsocks: microsocks_user is unset. Set it to an existing user and try again."
fi
install -m 0600 -o "${microsocks_user}" /dev/null "${pidfile}"
}

microsocks_poststop()
{
rm -f "${pidfile}"
}

run_rc_command "$1"

0 comments on commit 28cb794

Please sign in to comment.