pkgsrc-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[pkgsrc/trunk]: pkgsrc/net/transmission transmission: Add a rc script to auto...



details:   https://anonhg.NetBSD.org/pkgsrc/rev/4c9d7288b025
branches:  trunk
changeset: 391211:4c9d7288b025
user:      nia <nia%pkgsrc.org@localhost>
date:      Thu Jan 05 15:55:38 2023 +0000

description:
transmission: Add a rc script to automatically run transmission as a
dedicated user out of the box. Reviewed by wiz.

diffstat:

 net/transmission/Makefile              |  28 ++++++++++++++++-
 net/transmission/files/transmission.sh |  53 ++++++++++++++++++++++++++++++++++
 2 files changed, 79 insertions(+), 2 deletions(-)

diffs (98 lines):

diff -r d3420f9286b0 -r 4c9d7288b025 net/transmission/Makefile
--- a/net/transmission/Makefile Thu Jan 05 15:32:36 2023 +0000
+++ b/net/transmission/Makefile Thu Jan 05 15:55:38 2023 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile,v 1.31 2022/10/26 10:31:52 wiz Exp $
+# $NetBSD: Makefile,v 1.32 2023/01/05 15:55:38 nia Exp $
 
 CONFLICTS+=    Transmission-[0-9]*
 
@@ -8,6 +8,30 @@
 CONFIGURE_ARGS+=       --disable-mac
 CONFIGURE_ARGS+=       --without-gtk
 
-PKGREVISION= 4
+PKGREVISION=   5
+
+RCD_SCRIPTS=           transmission
+
+BUILD_DEFS+=           VARBASE
+
+.include "../../mk/bsd.prefs.mk"
+
+TRANSMISSION_USER?=    transmission
+TRANSMISSION_GROUP?=   transmission
+
+FILES_SUBST+=          TRANSMISSION_USER=${TRANSMISSION_USER}
+FILES_SUBST+=          TRANSMISSION_GROUP=${TRANSMISSION_GROUP}
+
+PKG_USERS_VARS+=       TRANSMISSION_USER
+PKG_GROUPS_VARS+=      TRANSMISSION_GROUP
+
+PKG_GROUPS=            ${TRANSMISSION_GROUP}
+PKG_USERS=             ${TRANSMISSION_USER}:${TRANSMISSION_GROUP}
+
+OWN_DIRS_PERMS+=       ${PKG_SYSCONFDIR}/transmission \
+                       ${TRANSMISSION_USER} ${TRANSMISSION_GROUP} 0755
+OWN_DIRS_PERMS+=       ${VARBASE}/log/transmission \
+                       ${TRANSMISSION_USER} ${TRANSMISSION_GROUP} 0755
+
 .include "../../net/transmission/Makefile.common"
 .include "../../mk/bsd.pkg.mk"
diff -r d3420f9286b0 -r 4c9d7288b025 net/transmission/files/transmission.sh
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/net/transmission/files/transmission.sh    Thu Jan 05 15:55:38 2023 +0000
@@ -0,0 +1,53 @@
+#!@RCD_SCRIPTS_SHELL@
+#
+# PROVIDE: transmission
+# REQUIRE: DAEMON
+# KEYWORD: shutdown
+#
+
+if [ -f /etc/rc.subr ]
+then
+       . /etc/rc.subr
+fi
+
+name="transmission"
+rcvar=${name}
+pidfile="@VARBASE@/run/transmission/pid"
+transmission_file_path="@VARBASE@/db/transmission"
+command="@PREFIX@/bin/transmission-daemon"
+command_args="--pid-file ${pidfile}"
+command_args="${command_args} --logfile @VARBASE@/log/transmission/log"
+command_args="${command_args} --config-dir @PKG_SYSCONFDIR@/transmission"
+command_args="${command_args} --download-dir ${transmission_file_path}/complete"
+command_args="${command_args} --incomplete-dir ${transmission_file_path}/incomplete"
+command_args="${command_args} --watch-dir ${transmission_file_path}/torrents"
+start_precmd="transmission_precmd"
+transmission_user="@TRANSMISSION_USER@"
+transmission_group="@TRANSMISSION_GROUP@"
+
+transmission_precmd()
+{
+       if [ ! -d "@VARBASE@/run/transmission" ]; then
+               mkdir -p -m 755 "@VARBASE@/run/transmission"
+               chown @TRANSMISSION_USER@:@TRANSMISSION_GROUP@ \
+                       "@VARBASE@/run/transmission"
+       fi
+       if [ ! -d "${transmission_file_path}/complete" ]; then
+               mkdir -p -m 755 "${transmission_file_path}/complete"
+               chown @TRANSMISSION_USER@:@TRANSMISSION_GROUP@ \
+                       "${transmission_file_path}/complete"
+       fi
+       if [ ! -d "${transmission_file_path}/incomplete" ]; then
+               mkdir -p -m 755 "${transmission_file_path}/incomplete"
+               chown @TRANSMISSION_USER@:@TRANSMISSION_GROUP@ \
+                       "${transmission_file_path}/incomplete"
+       fi
+       if [ ! -d "${transmission_file_path}/torrents" ]; then
+               mkdir -p -m 755 "${transmission_file_path}/torrents"
+               chown @TRANSMISSION_USER@:@TRANSMISSION_GROUP@ \
+                       "${transmission_file_path}/torrents"
+       fi
+}
+
+load_rc_config $name
+run_rc_command "$1"



Home | Main Index | Thread Index | Old Index