aboutsummaryrefslogtreecommitdiff
path: root/contrib/services/openrc
diff options
context:
space:
mode:
Diffstat (limited to 'contrib/services/openrc')
-rw-r--r--contrib/services/openrc/gnunet.initd82
1 files changed, 82 insertions, 0 deletions
diff --git a/contrib/services/openrc/gnunet.initd b/contrib/services/openrc/gnunet.initd
new file mode 100644
index 000000000..c042e3de1
--- /dev/null
+++ b/contrib/services/openrc/gnunet.initd
@@ -0,0 +1,82 @@
1#!/sbin/openrc-run
2# Copyright 1999-2016 Gentoo Foundation
3# Distributed under the terms of the GNU General Public License v2
4
5if [ -d /run ] ; then
6 PIDFILE=${PIDFILE:-/run/gnunet/arm-service.pid}
7else
8 PIDFILE=${PIDFILE:-/var/run/gnunet/arm-service.pid}
9fi
10
11depend() {
12 # FIXME: refine?
13 need net
14}
15
16GNUNET_PATH="/usr"
17GNUNET_HOME="/var/lib/gnunet"
18SUID_ROOT_HELPERS="exit nat-server nat-client transport-bluetooth transport-wlan vpn"
19
20chmodown_execbin() {
21 if [ -x $1 ]; then
22 if [ "$3" ]; then
23 chown $3 $1 2>/dev/null && chmod $2 $1
24 else
25 chmod $2 $1
26 fi
27 fi
28}
29
30checkconfig() {
31 if [ -n "$(find ${GNUNET_HOME}/.local/share/gnunet -maxdepth 1 -name gnunet.conf -perm +0044)" ] ; then
32 eerror "${conf} must not be world or group readable. Try:"
33 eerror " chmod 600 ${conf}"
34 eerror " chown gnunet:gnunet ${conf}"
35 return 1
36 fi
37 mkdir -p ${GNUNET_HOME}/.cache/gnunet
38
39 # taken from dangole's lede config.. thx!
40 local libexec="${GNUNET_PATH}/lib/gnunet/libexec" # why not /usr/libexec/gnunet ?
41 # not reliable enough:
42 #[ -e ${libexec}/.permfix ] && return
43 for helper in $SUID_ROOT_HELPERS; do
44 chmodown_execbin ${libexec}/gnunet-helper-$helper u+s
45 done
46 chmodown_execbin ${libexec}/gnunet-helper-dns 4750 root:gnunetdns
47 chmodown_execbin ${libexec}/gnunet-service-dns 2750 gnunet:gnunetdns
48 #touch ${libexec}/.permfix
49}
50
51start() {
52 checkconfig || return 1
53
54 local piddir=$(dirname ${PIDFILE})
55 if [ ! -d ${piddir} ] ; then
56 ebegin "Making ${piddir}"
57 mkdir -p ${piddir}
58 eend $?
59 ebegin "Changing permissions of ${piddir}"
60 chown gnunet:gnunet ${piddir}
61 eend $?
62 fi
63
64 ebegin "Starting ${SVCNAME}"
65 # shouldn't be necessary... but
66 start-stop-daemon --start --user gnunet --name gnunet --pidfile ${PIDFILE} \
67 --exec ${GNUNET_PATH}/lib/gnunet/libexec/gnunet-service-arm -- -d
68 # flags to be passed to the process appear after the double-dash
69 eend $?
70}
71
72stop() {
73 ebegin "Stopping ${SVCNAME}"
74 start-stop-daemon --stop --signal QUIT --pidfile ${PIDFILE}
75 sleep 1
76 killall -u gnunet
77 sleep 1
78 rm -rf /tmp/gnunet-gnunet-runtime >/dev/null 2>&1
79 rm -rf /tmp/gnunet-system-runtime >/dev/null 2>&1
80 eend $?
81}
82