git: d50cf73e428d - main - net/rathole: Add init/rc.d-script and pkg-message
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Sun, 01 Oct 2023 02:12:30 UTC
The branch main has been updated by yuri: URL: https://cgit.FreeBSD.org/ports/commit/?id=d50cf73e428d2264b5208fe746778fff404108db commit d50cf73e428d2264b5208fe746778fff404108db Author: kaltheat <kaltheat@gmail.com> AuthorDate: 2023-10-01 02:11:45 +0000 Commit: Yuri Victorovich <yuri@FreeBSD.org> CommitDate: 2023-10-01 02:12:28 +0000 net/rathole: Add init/rc.d-script and pkg-message PR: 274176 --- net/rathole/files/pkg-message.in | 27 ++++++++++++++++++++ net/rathole/files/rathole.in | 53 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 80 insertions(+) diff --git a/net/rathole/files/pkg-message.in b/net/rathole/files/pkg-message.in new file mode 100644 index 000000000000..a5a59b24227d --- /dev/null +++ b/net/rathole/files/pkg-message.in @@ -0,0 +1,27 @@ +[ +{ type: install + message: <<EOM +To enable %%NAME%% at startup, add the following line to your 'rc.conf': +%%NAME%%_enable="YES" + +Configure %%NAME%% by editing '%%ETCDIR%%/%%NAME%%.conf'. +Example configurations can be found here: + https://github.com/rapiz1/rathole/tree/main/examples + +Run + service %%NAME%% rcvar +to learn about existing rc script parameters and their defaults. + +Note that there are two operating modes for %%NAME%%: server or +client. + +Note that the rc script runs %%NAME%% as user 'nobody' by default. +This might lead to permission problems since the user is not +allowed to open ports below 1024. +If you really need %%NAME%% to react on a port below 1024, you +could configure your firewall to redirect traffic to a higher +port (e.g. redirect port 80 to port 8080 where %%NAME%% listens). + +EOM +} +] diff --git a/net/rathole/files/rathole.in b/net/rathole/files/rathole.in new file mode 100644 index 000000000000..125f3a8e3df0 --- /dev/null +++ b/net/rathole/files/rathole.in @@ -0,0 +1,53 @@ +#!/bin/sh + +# PROVIDE: %%NAME%% +# REQUIRE: DAEMON NETWORKING +# KEYWORD: shutdown + +# Add the following lines to /etc/rc.conf to enable `%%NAME%%': +# +# %%NAME%%_enable (bool): Set to "NO" by default. +# Set it to "YES" to enable %%NAME%% +# %%NAME%%_conf_file (str): Path to config file. +# Set to "%%ETCDIR%%/%%NAME%%.conf" by default. +# %%NAME%%_mode (str): Mode %%NAME%% runs in. +# Set to "server" by default. +# Set it to "client" to run in client-mode. +# %%NAME%%_user (str): User that runs %%NAME%%. +# Set to "nobody" by default. +# + +. /etc/rc.subr + +name="%%NAME%%" +rcvar=%%NAME%%_enable +desc="rc script to start/stop %%NAME%%" + +set_rcvar %%NAME%%_conf_file "%%ETCDIR%%/${name}.conf" "Path to config file" +set_rcvar %%NAME%%_mode "server" "Mode %%NAME%% runs in (either 'server' or 'client')" +set_rcvar %%NAME%%_user "nobody" "User that runs %%NAME%%" + +load_rc_config "$name" + +pidfile="%%PIDDIR%%/${name}.pid" +logfile="%%LOGDIR%%/${name}.log" +run_mode_param=--server + +command=/usr/sbin/daemon +actual_command="%%PREFIX%%/bin/%%NAME%%" +start_precmd=%%NAME%%_prestart +command_args="-H -P \${pidfile} -t \${name} -u \${%%NAME%%_user} -o \${logfile} ${actual_command} \${run_mode_param} \${%%NAME%%_conf_file}" + +%%NAME%%_prestart() +{ + case $%%NAME%%_mode in + client) + run_mode_param="--client" + ;; + *) + run_mode_param="--server" + ;; + esac +} + +run_rc_command "$1"