pkgsrc-WIP-changes archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
gnunet: make the rc.d service work, add additional user service.
Module Name: pkgsrc-wip
Committed By: ng0 <ng0%NetBSD.org@localhost>
Pushed By: ng0
Date: Thu Oct 24 17:50:28 2019 +0000
Changeset: 547b2ec350e7399bb9ed2142488477f913a3e306
Modified Files:
gnunet/Makefile
gnunet/files/gnunet.conf
gnunet/files/gnunet.in
Added Files:
gnunet/files/gnunetuser.in
Log Message:
gnunet: make the rc.d service work, add additional user service.
To see a diff of this commit:
https://wip.pkgsrc.org/cgi-bin/gitweb.cgi?p=pkgsrc-wip.git;a=commitdiff;h=547b2ec350e7399bb9ed2142488477f913a3e306
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
diffstat:
gnunet/Makefile | 66 ++++++++++++++++---------------
gnunet/files/gnunet.conf | 6 +--
gnunet/files/gnunet.in | 66 ++++++++++++++++---------------
gnunet/files/gnunetuser.in | 96 ++++++++++++++++++++++++++++++++++++++++++++++
4 files changed, 170 insertions(+), 64 deletions(-)
diffs:
diff --git a/gnunet/Makefile b/gnunet/Makefile
index 4eff3fdaf7..789e9f9a52 100644
--- a/gnunet/Makefile
+++ b/gnunet/Makefile
@@ -9,6 +9,7 @@ HOMEPAGE= https://gnunet.org/
COMMENT= Framework for secure P2P networking
LICENSE= gnu-agpl-v3
+# Remove c++ with 0.11.7
USE_TOOLS+= msgfmt
USE_LANGUAGES= c c++
GNU_CONFIGURE= yes
@@ -28,34 +29,36 @@ CONFIGURE_ARGS+= --sysconfdir=${PKG_SYSCONFDIR}
CONFIGURE_ARGS+= --with-extractor=${BUILDLINK_PREFIX.libextractor}
CONFIGURE_ARGS+= --with-gnunetdns=gnunetdns
-GNUNET_DIR?= ${VARBASE}/chroot/gnunet
-GNUNET_LOG_DIR?= ${VARBASE}/log/gnunet
-GNUNET_USER= gnunet
-GNUNET_GROUP= gnunet
-GNUNETDNS_GROUP= gnunetdns
-PKG_SYSCONFSUBDIR= gnunet
+GNUNET_DIR= ${VARBASE}/chroot/gnunet
+GNUNET_LOG_DIR?= ${VARBASE}/log/gnunet
+GNUNET_USER= gnunet
+GNUNET_GROUP= gnunet
+GNUNETDNS_GROUP= gnunetdns
+PKG_SYSCONFSUBDIR= gnunet
-PKG_GROUPS+= ${GNUNET_GROUP}
-PKG_GROUPS+= ${GNUNETDNS_GROUP}
-PKG_USERS+= ${GNUNET_USER}:${GNUNET_GROUP}
-PKG_GECOS.gnunet= GNUnet System user
-PKG_HOME.gnunet= ${GNUNET_DIR}
+PKG_GROUPS+= ${GNUNET_GROUP}
+PKG_GROUPS+= ${GNUNETDNS_GROUP}
+PKG_USERS+= ${GNUNET_USER}:${GNUNET_GROUP}
+PKG_GECOS.gnunet= GNUnet System user
+PKG_HOME.gnunet= ${GNUNET_DIR}
-RCD_SCRIPTS= gnunet
+RCD_SCRIPTS= gnunet gnunetuser
RCD_SCRIPT_SRC.gnunet= ${FILESDIR}/gnunet.in
+RCD_SCRIPT_SRC.gnunetuser= ${FILESDIR}/gnunetuser.in
-OWN_DIRS_PERMS+= ${GNUNET_DIR} ${GNUNET_USER} ${GNUNET_GROUP} 0700
-OWN_DIRS_PERMS+= ${GNUNET_LOG_DIR} ${GNUNET_USER} ${GNUNET_GROUP} 0755
-OWN_DIRS_PERMS+= ${GNUNET_DIR}/data ${GNUNET_USER} ${GNUNET_GROUP} 0700
+OWN_DIRS_PERMS+= ${PKG_HOME.gnunet} ${GNUNET_USER} ${GNUNET_GROUP} 0700
+OWN_DIRS_PERMS+= ${GNUNET_LOG_DIR} ${GNUNET_USER} ${GNUNET_GROUP} 0755
+OWN_DIRS_PERMS+= ${GNUNET_DIR}/data ${GNUNET_USER} ${GNUNET_GROUP} 0700
-MAKE_DIRS+= ${PKG_SYSCONFDIR}
-MAKE_DIRS+= ${GNUNET_LOG_DIR}
-MAKE_DIRS+= ${GNUNET_DIR}/data
-AUTO_MKDIRS= YES
-CONF_FILES+= ${FILESDIR}/gnunet.conf \
- ${PKG_SYSCONFDIR}/gnunet.conf
+MAKE_DIRS+= ${PKG_SYSCONFDIR}
+MAKE_DIRS+= ${GNUNET_DIR}
+MAKE_DIRS+= ${GNUNET_LOG_DIR}
+MAKE_DIRS+= ${GNUNET_DIR}/data
+AUTO_MKDIRS= YES
+CONF_FILES+= ${FILESDIR}/gnunet.conf \
+ ${PKG_SYSCONFDIR}/gnunet.conf
-FILES_SUBST+= PKG_HOME=${GNUNET_DIR}
+FILES_SUBST+= PKG_HOME=${GNUNET_DIR}
SUBST_CLASSES+= sysconfdir
SUBST_STAGE.sysconfdir= post-build
@@ -67,21 +70,24 @@ SUBST_SED.sysconfdir+= -e 's,^GNUNET_RUNTIME_DIR.*,GNUNET_RUNTIME_DIR = ${GNUNE
SUBST_SED.sysconfdir+= -e 's,^GNUNET_HOME.*,GNUNET_HOME = ${GNUNET_DIR},g'
# All helpers have to be suid. fs helper must not be suid.
-# Not all of these files may be available.
-# This is only necessary when the installation was not run
-# as root. Run it to ensure that no manual intervention is
-# necessary.
+# Some helpers and functionalities are only supported on
+# some Operating Systems so far.
+SPECIAL_PERMS+= ${PREFIX}/lib/gnunet/libexec/gnunet-helper-testbed ${SETUID_ROOT_PERMS}
+.if ${OPSYS} == "Linux"
# ${CHMOD} root:${GNUNETDNS_GROUP} ${DESTDIR}${PREFIX}/lib/gnunet/libexec/gnunet-helper-dns
# ${CHMOD} ${GNUNET_USER}:${GNUNETDNS_GROUP} ${DESTDIR}${PREFIX}/lib/gnunet/libexec/gnunet-service-dns
SPECIAL_PERMS+= ${PREFIX}/lib/gnunet/libexec/gnunet-helper-dns ${REAL_ROOT_USER} ${GNUNETDNS_GROUP} 4750
SPECIAL_PERMS+= ${PREFIX}/lib/gnunet/libexec/gnunet-service-dns ${GNUNET_USER} ${GNUNETDNS_GROUP} 2750
-SPECIAL_PERMS+= ${PREFIX}/lib/gnunet/libexec/gnunet-helper-testbed ${SETUID_ROOT_PERMS}
SPECIAL_PERMS+= ${PREFIX}/lib/gnunet/libexec/gnunet-helper-exit ${SETUID_ROOT_PERMS}
-SPECIAL_PERMS+= ${PREFIX}/lib/gnunet/libexec/gnunet-helper-nat-client ${SETUID_ROOT_PERMS}
-SPECIAL_PERMS+= ${PREFIX}/lib/gnunet/libexec/gnunet-helper-nat-server ${SETUID_ROOT_PERMS}
SPECIAL_PERMS+= ${PREFIX}/lib/gnunet/libexec/gnunet-helper-transport-bluetooth ${SETUID_ROOT_PERMS}
SPECIAL_PERMS+= ${PREFIX}/lib/gnunet/libexec/gnunet-helper-transport-wlan ${SETUID_ROOT_PERMS}
SPECIAL_PERMS+= ${PREFIX}/lib/gnunet/libexec/gnunet-helper-vpn ${SETUID_ROOT_PERMS}
+.endif
+.if ${OPSYS} == "Linux" || ${OPSYS} == "FreeBSD"
+SPECIAL_PERMS+= ${PREFIX}/lib/gnunet/libexec/gnunet-helper-nat-client ${SETUID_ROOT_PERMS}
+SPECIAL_PERMS+= ${PREFIX}/lib/gnunet/libexec/gnunet-helper-nat-server ${SETUID_ROOT_PERMS}
+.endif
+
.include "../../databases/sqlite3/buildlink3.mk"
.include "../../devel/gettext-lib/buildlink3.mk"
@@ -91,7 +97,7 @@ SPECIAL_PERMS+= ${PREFIX}/lib/gnunet/libexec/gnunet-helper-vpn ${SETUID_ROOT_PER
.include "../../devel/libextractor/buildlink3.mk"
.include "../../devel/libgsf/buildlink3.mk"
.include "../../devel/libltdl/buildlink3.mk"
-.include "../../wip/gnutls/buildlink3.mk"
+.include "../../security/gnutls/buildlink3.mk"
.include "../../security/libgcrypt/buildlink3.mk"
.include "../../textproc/libunistring/buildlink3.mk"
.include "../../textproc/jansson/buildlink3.mk"
diff --git a/gnunet/files/gnunet.conf b/gnunet/files/gnunet.conf
index 3ded6eb4b3..28638b9821 100644
--- a/gnunet/files/gnunet.conf
+++ b/gnunet/files/gnunet.conf
@@ -1,8 +1,8 @@
[PATHS]
DEFAULTCONFIG = /usr/pkg/etc/gnunet/gnunet.conf
-GNUNET_DATA_HOME = @GNUNET_DIR@/data/
-GNUNET_RUNTIME_DIR = @GNUNET_DIR@
-GNUNET_HOME = @GNUNET_DIR@
+GNUNET_DATA_HOME = /var/chroot/gnunet/data
+GNUNET_RUNTIME_DIR = /var/chroot/gnunet
+GNUNET_HOME = /var/chroot/gnunet
# choose your database backend
#[datastore]
diff --git a/gnunet/files/gnunet.in b/gnunet/files/gnunet.in
index d9e6ac52f3..eeec9077b2 100755
--- a/gnunet/files/gnunet.in
+++ b/gnunet/files/gnunet.in
@@ -15,33 +15,31 @@ fi
name="gnunet"
rcvar=${name}
-command="@PREFIX@/bin/gnunet-arm"
+command="@PREFIX@/lib/gnunet/libexec/gnunet-service-arm"
command_args="-c @PKG_SYSCONFDIR@/gnunet.conf"
required_files="@PKG_SYSCONFDIR@/gnunet.conf"
-pidfile="@PKG_HOME@/${name}.pid"
+pidfile="/dev/null"
: ${gnunet_user:=gnunet}
: ${gnunet_group:=gnunet}
-: ${gnunet_home:=@PKG_HOME@}
+: ${gnunet_home:=@VARBASE@/chroot/gnunet}
: ${gnunetdns_group:=gnunetdns}
start_cmd="gnunet_start"
start_precmd="gnunet_precmd"
-stop_cmd="gnunet_stop"
-restart_cmd="gnunet_stop ; gnunet_start"
-restart_precmd="gnunet_precmd"
+#stop_cmd="gnunet_stop"
+#restart_cmd="gnunet_stop ; gnunet_start"
+#restart_precmd="gnunet_precmd"
-gnunet_env="HOME=${gnunet_home} USER=${gnunet_user} TMP=/tmp"
+gnunet_env="HOME=${gnunet_home} USER=${gnunet_user} TMP=/tmp GNUNET_PREFIX=@PREFIX@"
+
+check_pidfile()
+{
+ pid=$(pgrep -U "${gnunet_user}" "${command}"$)
+ echo -n "${pid}"
+}
gnunet_precmd()
{
- if [ -f ${gnunet_home}/data/gnunet.conf ]; then
- @CHMOD@ 0600 @PKG_HOME@/data/gnunet.conf
- @CHOWN@ gnunet:gnunet @PKG_HOME@/data/gnunet.conf
- fi
- if [ ! -d ${gnunet_home}/.cache/gnunet ]; then
- @MKDIR@ -p ${gnunet_home}/.cache/gnunet
- @CHOWN@ gnunet:gnunet ${gnunet_home}/.cache/gnunet
- fi
if [ ! -f ${required_files} ]; then
warn "${required_files} does not exist."
return 1
@@ -51,38 +49,44 @@ gnunet_precmd()
gnunet_start()
{
@ECHO@ "Starting ${name}."
- doit="@SU@ -m ${gnunet_user} -c '${gnunet_env} ${command} ${command_args} -s'"
+ doit="@SU@ -m ${gnunet_user} -c '${gnunet_env} ${command} ${command_args}'"
eval $doit
}
-gnunet_stop()
-{
- @ECHO@ "Stopping ${name}."
- doit="@SU@ -m ${gnunet_user} -c '${gnunet_env} ${command} ${command_args} -e'"
- eval $doit
- # kill `cat ${pidfile}` 2>/dev/null
- sleep 1
- rm -rf /tmp/gnunet-gnunet-runtime 2>/dev/null 2>&1
- rm -rf /tmp/gnunet-system-runtime 2>/dev/null 2>&1
-}
+#gnunet_stop()
+#{
+# @ECHO@ "Stopping ${name}."
+# # doit="@SU@ -m ${gnunet_user} -c '${gnunet_env} ${command} ${command_args} -e'"
+# # eval $doit
+# # kill `cat ${pidfile}` 2>/dev/null
+# check_pidfile
+# kill ${pid}
+# sleep 1
+# rm -rf /tmp/gnunet-gnunet-runtime 2>/dev/null 2>&1
+# rm -rf /tmp/gnunet-system-runtime 2>/dev/null 2>&1
+#}
if [ -f /etc/rc.subr -a -f /etc/rc.conf -a -d /etc/rc.d -a -f /etc/rc.d/DAEMON ]; then
+ # newer NetBSD
load_rc_config $name
run_rc_command "$1"
else
+ # old NetBSD, Solaris and illumos, Linux, etc.
pidfile="${gnunet_home}/${name}.pid"
cmd=${1:-start}
case ${cmd} in
restart)
- eval ${restart_precmd}
- eval ${restart_cmd}
+ ( $0 stop )
+ sleep 5
+ $0 start
;;
stop)
- if [ -r "${pidfile}" ]; then
- eval ${stop_cmd}
- fi
+ echo "Stopping ${name}."
+ check_pidfile
+ ! [ -n ${pid} ] && eval ${stop_cmd}
;;
start)
+ echo "Starting ${name}."
eval ${start_precmd}
eval ${start_cmd}
;;
diff --git a/gnunet/files/gnunetuser.in b/gnunet/files/gnunetuser.in
new file mode 100755
index 0000000000..f2767ca5dd
--- /dev/null
+++ b/gnunet/files/gnunetuser.in
@@ -0,0 +1,96 @@
+#!@RCD_SCRIPTS_SHELL@
+#
+# PROVIDE: gnunetuser
+# REQUIRE: DAEMON NETWORKING LOGIN gnunet
+# KEYWORD: shutdown
+#
+# You will need to set some variables in /etc/rc.conf to start gnunet:
+#
+# gnunetuser=YES
+
+if [ -f /etc/rc.subr ]
+then
+ . /etc/rc.subr
+fi
+
+name="gnunetuser"
+rcvar=${name}
+command="@PREFIX@/bin/gnunet-arm"
+
+: ${gnunetuser_user_home:=/home/nowhere}
+: ${gnunetuser_user:=noone}
+
+if [ -f /etc/rc.subr -a -d /etc/rc.d -a -f /etc/rc.d/DAEMON ]; then
+ load_rc_config $name
+elif [ -f /etc/rc.conf ]; then
+ . /etc/rc.conf
+fi
+
+command_args="-c ${gnunetuser_user_home}/.config/gnunet.conf"
+required_files="${gnunetuser_user_home}/.config/gnunet.conf"
+pidfile="/dev/null"
+
+start_cmd="gnunet_start"
+start_precmd="gnunet_precmd"
+stop_cmd="gnunet_stop"
+
+gnunet_env="HOME=${gnunetuser_user_home} USER=${gnunetuser_user} TMP=/tmp GNUNET_PREFIX=@PREFIX@"
+
+check_pidfile()
+{
+ pid=$(pgrep -U "$gnunetuser_user" "${command}"$)
+ echo -n "${pid}"
+}
+
+gnunet_precmd()
+{
+ if [ ! -f ${required_files} ]; then
+ warn "${required_files} does not exist."
+ return 1
+ fi
+}
+
+gnunet_start()
+{
+ @ECHO@ "Starting ${name}."
+ doit="@SU@ -m ${gnunetuser_user} -c '${gnunet_env} ${command} ${command_args} -s'"
+ eval $doit
+}
+
+gnunet_stop()
+{
+ @ECHO@ "Stopping ${name}."
+ doit="@SU@ -m ${gnunetuser_user} -c '${gnunet_env} ${command} ${command_args} -e'"
+ eval $doit
+}
+
+if [ -f /etc/rc.subr -a -f /etc/rc.conf -a -d /etc/rc.d -a -f /etc/rc.d/DAEMON ]; then
+ # newer NetBSD
+ load_rc_config $name
+ run_rc_command "$1"
+else
+ # old NetBSD, Solaris and illumos, Linux, etc.
+ cmd=${1:-start}
+ case ${cmd} in
+ restart)
+ ( $0 stop )
+ sleep 5
+ $0 start
+ ;;
+ stop)
+ echo "Stopping ${name}."
+ check_pidfile
+ ! [ -n ${pid} ] && eval ${stop_cmd}
+ ;;
+ start)
+ echo "Starting ${name}."
+ eval ${start_precmd}
+ eval ${start_cmd}
+ ;;
+ *)
+ echo 1>&2 "Usage: $0 [start|stop|restart]"
+ exit 1
+ ;;
+ esac
+ exit 0
+fi
Home |
Main Index |
Thread Index |
Old Index