Skip to content

Commit d4aa8e1

Browse files
author
Steve Arnold
authored
Merge pull request #42 from freepn/systemd
Systemd and openrc updates for (missing) site_state_dir on Linux (see PR #150 ActiveState/appdirs#150)
2 parents 356b7d8 + 36cd0e4 commit d4aa8e1

5 files changed

Lines changed: 32 additions & 8 deletions

File tree

etc/fpnd.ini

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,5 +10,5 @@ pid_name = fpnd.pid
1010

1111
[Paths]
1212
home_dir = /usr/lib/fpnd/
13-
log_path = /var/log/
14-
pid_path = /run/
13+
log_path = /var/log/fpnd
14+
pid_path = /run/fpnd

etc/fpnd.openrc

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,16 @@
11
#!/sbin/openrc-run
2-
# Copyright 1999-2019 Gentoo Authors
2+
# Copyright 1999-2020 Gentoo Authors
33
# Distributed under the terms of the GNU General Public License v2
44

5+
: ${FPND_STATE_DIR:=/var/lib/${RC_SVCNAME}}
6+
: ${FPND_GROUP:=root}
7+
: ${FPND_USER:=root}
8+
59
CONFIG="/etc/fpnd/fpnd.ini"
610

711
description="fpnd - FreePN daemon"
8-
command="/usr/sbin/fpnd.py"
9-
pidfile="/run/${SVCNAME}.pid"
12+
command="/usr/bin/fpnd.py"
13+
pidfile="/run/${RC_SVCNAME}.pid"
1014
command_args="start"
1115

1216
depend() {
@@ -19,4 +23,14 @@ start_pre() {
1923
eerror "Configuration file ${CONFIG} not found"
2024
return 1
2125
fi
26+
checkpath \
27+
-d \
28+
--mode 0755 \
29+
--owner ${FPND_USER}:${FPND_GROUP} \
30+
"${FPND_STATE_DIR}"
31+
}
32+
33+
stop_pre() {
34+
[ "${RC_CMD}" = "restart" ] && sleep 1
35+
return 0
2236
}

etc/fpnd.service

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,21 @@ Requires=zerotier-one.service
44
After=zerotier-one.service
55

66
[Service]
7+
User=fpnd
8+
Group=fpnd
9+
10+
RuntimeDirectory=fpnd
11+
LogsDirectory=fpnd
12+
StateDirectory=fpnd
13+
14+
AmbientCapabilities=CAP_NET_ADMIN CAP_NET_RAW CAP_DAC_OVERRIDE
15+
CapabilityBoundingSet=CAP_NET_ADMIN CAP_NET_RAW CAP_DAC_OVERRIDE
16+
717
ExecStart=/usr/lib/fpnd/fpnd.py start
818
ExecStop=/bin/kill -TERM $MAINPID
919
KillMode=none
10-
PIDFile=/run/fpnd.pid
1120
Type=forking
21+
PIDFile=/run/fpnd/fpnd.pid
1222
TimeoutStartSec=5
1323
TimeoutStopSec=7
1424

node_tools/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,5 +83,5 @@
8383
'wait_for_moon',
8484
]
8585

86-
__version__ = '0.8.9'
86+
__version__ = '0.8.10'
8787
__version_info__ = tuple(int(segment) for segment in __version__.split('.'))

node_tools/helper_funcs.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ def get_cachedir(dir_name='fpn_cache', user_dirs=False):
146146
dirs = AppDirs('fpnd', 'FreePN')
147147
temp_dir = dirs.user_cache_dir
148148
if not user_dirs and not NODE_SETTINGS['runas_user']:
149-
temp_dir = dirs.site_data_dir
149+
temp_dir = '/var/lib/fpnd'
150150

151151
if not os.access(temp_dir, os.X_OK | os.W_OK):
152152
logger.error('Cannot use path {}!'.format(temp_dir))

0 commit comments

Comments
 (0)