diff options
author | Nils Gillmann <ng0@n0.is> | 2018-06-05 08:54:29 +0000 |
---|---|---|
committer | Nils Gillmann <ng0@n0.is> | 2018-06-05 08:54:29 +0000 |
commit | 52de9c044b048de3f1ba4d6d4d59dc62a6fab5f9 (patch) | |
tree | 64f12e7540a19462054a5087344e9b4cb288c630 /contrib | |
parent | a37d06cb367b57636b11c9224c2e28458614aca6 (diff) | |
download | gnunet-52de9c044b048de3f1ba4d6d4d59dc62a6fab5f9.tar.gz gnunet-52de9c044b048de3f1ba4d6d4d59dc62a6fab5f9.zip |
Add GPL2 licensed openrc service file
Signed-off-by: Nils Gillmann <ng0@n0.is>
Diffstat (limited to 'contrib')
-rw-r--r-- | contrib/services/openrc/gnunet.initd | 82 |
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 | |||
5 | if [ -d /run ] ; then | ||
6 | PIDFILE=${PIDFILE:-/run/gnunet/arm-service.pid} | ||
7 | else | ||
8 | PIDFILE=${PIDFILE:-/var/run/gnunet/arm-service.pid} | ||
9 | fi | ||
10 | |||
11 | depend() { | ||
12 | # FIXME: refine? | ||
13 | need net | ||
14 | } | ||
15 | |||
16 | GNUNET_PATH="/usr" | ||
17 | GNUNET_HOME="/var/lib/gnunet" | ||
18 | SUID_ROOT_HELPERS="exit nat-server nat-client transport-bluetooth transport-wlan vpn" | ||
19 | |||
20 | chmodown_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 | |||
30 | checkconfig() { | ||
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 | |||
51 | start() { | ||
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 | |||
72 | stop() { | ||
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 | |||