aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYusuf Yaman <nxjoseph@protonmail.com>2024-08-11 16:37:56 +0000
committerVladimir Druzenko <vvd@FreeBSD.org>2024-08-11 16:37:56 +0000
commita1c9f292ea984baa1ed473910c8f2d39998c956a (patch)
tree7a9425425d30eb67a2cbb895619c62722e3ba593
parent2a5ca2411c186da6785fd597611f7bc82dd0cf20 (diff)
mail/hydroxide: Add rc.d script to run as daemon and minor changes to Makefile
Changes: * Add rc.d script to run as daemon because users had to run the port somehow in the background on terminal. * Minor changes to Makefile. PR: 280754
-rw-r--r--GIDs2
-rw-r--r--UIDs2
-rw-r--r--mail/hydroxide/Makefile13
-rw-r--r--mail/hydroxide/files/hydroxide.in43
4 files changed, 53 insertions, 7 deletions
diff --git a/GIDs b/GIDs
index bf70d7250078..80afa5565441 100644
--- a/GIDs
+++ b/GIDs
@@ -321,7 +321,7 @@ _wsdd:*:370:
# free: 378
# free: 379
spoofdpi:*:380:
-# free: 381
+hydroxide:*:381:
# free: 382
# free: 383
# free: 384
diff --git a/UIDs b/UIDs
index 8c8d7e5c1d15..91822b11dd63 100644
--- a/UIDs
+++ b/UIDs
@@ -326,7 +326,7 @@ _wsdd:*:370:370::0:0:Web Service Discovery Daemon:/nonexistent:/usr/sbin/nologin
# free: 378
# free: 379
spoofdpi:*:380:380::0:0:SpoofDPI Daemon:/nonexistent:/usr/sbin/nologin
-# free: 381
+hydroxide:*:381:381::0:0:Hydroxide Daemon:/nonexistent:/usr/sbin/nologin
# free: 382
# free: 383
# free: 384
diff --git a/mail/hydroxide/Makefile b/mail/hydroxide/Makefile
index c961879118cf..c71c5b725d6b 100644
--- a/mail/hydroxide/Makefile
+++ b/mail/hydroxide/Makefile
@@ -1,7 +1,7 @@
PORTNAME= hydroxide
DISTVERSIONPREFIX= v
DISTVERSION= 0.2.29
-PORTREVISION= 2
+PORTREVISION= 3
CATEGORIES= mail
MAINTAINER= nxjoseph@protonmail.com
@@ -12,7 +12,6 @@ LICENSE= MIT
LICENSE_FILE= ${WRKSRC}/LICENSE
USES= go:modules
-
USE_GITHUB= yes
GH_ACCOUNT= emersion
GH_TUPLE= ProtonMail:go-crypto:v1.0.0:protonmail_go_crypto/vendor/github.com/ProtonMail/go-crypto \
@@ -31,9 +30,13 @@ GH_TUPLE= ProtonMail:go-crypto:v1.0.0:protonmail_go_crypto/vendor/github.com/Pro
golang:term:v0.19.0:golang_term/vendor/golang.org/x/term \
golang:text:v0.14.0:golang_text/vendor/golang.org/x/text
-GO_PKGNAME= github.com/${GH_ACCOUNT}/${PORTNAME}
-GO_TARGET= ./cmd/hydroxide
+USE_RC_SUBR= ${PORTNAME}
+GO_TARGET= ./cmd/${PORTNAME}
+GO_BUILDFLAGS= -ldflags="-s -w"
+SUB_LIST= USER=${USERS}
+USERS= ${PORTNAME}
+GROUPS= ${PORTNAME}
-PLIST_FILES= bin/hydroxide
+PLIST_FILES= bin/${PORTNAME}
.include <bsd.port.mk>
diff --git a/mail/hydroxide/files/hydroxide.in b/mail/hydroxide/files/hydroxide.in
new file mode 100644
index 000000000000..9bbc41c4853a
--- /dev/null
+++ b/mail/hydroxide/files/hydroxide.in
@@ -0,0 +1,43 @@
+#!/bin/sh
+
+# PROVIDE: hydroxide
+# REQUIRE: LOGIN
+# KEYWORD: shutdown
+#
+# Add the following lines to /etc/rc.conf or /etc/rc.conf.local to
+# enable hydroxide:
+# hydroxide_args (str): Custom additional arguments to be passed
+# hydroxide (default empty).
+# hydroxide_user (str): User to run hydroxide as. Default
+# to "%%USER%%" created by the port.
+# hydroxide_log (path): Console log file (default /dev/null).
+
+. /etc/rc.subr
+
+case $0 in
+/etc/rc*)
+ # during boot (shutdown) $0 is /etc/rc (/etc/rc.shutdown),
+ # so get the name of the script from $_file
+ name=$_file
+ ;;
+*)
+ name=$0
+ ;;
+esac
+
+name=${name##*/}
+rcvar="${name}_enable"
+
+load_rc_config "${name}"
+
+eval "${rcvar}=\${${rcvar}:-'NO'}"
+eval "_args=\${${name}_args:-''}"
+eval "_user=\${${name}_user:-'%%USER%%'}"
+eval "_log=\${${name}_log:-/dev/null}"
+
+pidfile="/var/run/${name}.pid"
+
+command="/usr/sbin/daemon"
+command_args="-P ${pidfile} -u ${_user} -f -H -o ${_log} -m 3 %%PREFIX%%/bin/hydroxide ${_args} serve"
+
+run_rc_command "$1"