Skip to content

Commit

Permalink
add systemd runtime directory support
Browse files Browse the repository at this point in the history
  • Loading branch information
knight-of-ni committed Nov 26, 2024
1 parent e7ef164 commit e7b75eb
Show file tree
Hide file tree
Showing 4 changed files with 82 additions and 48 deletions.
2 changes: 2 additions & 0 deletions distrib/initscripts/systemd.atalkd.service.in
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ After=network-online.target
[Service]
Type=forking
GuessMainPID=no
RuntimeDirectory=@runtimedir@
RuntimeDirectoryPreserve=yes
ExecStartPre=/bin/sh -c 'systemctl set-environment ATALK_NAME=$$(hostname|cut -d. -f1)'
ExecStart=@sbindir@/atalkd
ExecStartPost=-@bindir@/nbprgstr -p 4 "${ATALK_NAME}:Workstation"
Expand Down
2 changes: 2 additions & 0 deletions distrib/initscripts/systemd.netatalk.service.in
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ After=network.target avahi-daemon.service atalkd.service
Type=forking
GuessMainPID=no
ExecStart=@sbindir@/netatalk
RuntimeDirectory=@runtimedir@
RuntimeDirectoryPreserve=yes
PIDFile=@lockfile_path@
ExecReload=/bin/kill -HUP $MAINPID
Restart=always
Expand Down
120 changes: 72 additions & 48 deletions meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -1745,10 +1745,75 @@ else
endif

#
# Netatalk lockfile path
# Check for optional initscript install
#

init_style = get_option('with-init-style')
init_dirs = []
init_style_auto = false
init_cmd = ''

if 'auto' in init_style
init_style_auto = true
if host_os == 'linux'
if linux_distro in ['arch', 'centos', 'debian', 'fedora', 'rhel', 'suse', 'ubuntu']
init_style = ['systemd']
init_cmd = 'systemctl'
elif linux_distro in ['alpine', 'gentoo']
init_style = ['openrc']
init_cmd = 'rc-service'
endif
elif host_os == 'freebsd'
init_style = ['freebsd']
elif host_os == 'netbsd'
init_style = ['netbsd']
init_cmd = 'service'
elif host_os == 'openbsd'
init_style = ['openbsd']
init_cmd = 'rcctl'
elif host_os == 'darwin'
init_style = ['macos-launchd']
elif host_os == 'sunos'
init_style = ['solaris']
init_cmd = 'svcadm'
else
init_style = ['none']
endif
endif

if init_cmd != ''
init_program = find_program(init_cmd, required: not init_style_auto)
if not init_program.found()
warning(init_cmd + ' not found, defaulting to no init scripts')
init_style = ['none']
init_cmd = ''
endif
endif

#
# Setting Runtime Directory requires setting lockfile path
#
runtime_dir = get_option('with-runtime-dir')
lockfile_path = get_option('with-lockfile-path')

if runtime_dir != '' and lockfile_path == ''
error('Setting with-runtime-dir requires with-lockfile-path')
endif

#
# Netatalk Runtime Directory
#
runtimedir = ''

if runtime_dir != ''
runtimedir += runtime_dir
else
runtimedir = 'netatalk'
endif

#
# Netatalk lockfile path
#
lockfile = ''

if lockfile_path != ''
Expand All @@ -1758,7 +1823,11 @@ elif host_os == 'freebsd'
elif host_os in ['netbsd', 'openbsd', 'darwin']
lockfile += '/var/run/netatalk.pid'
elif host_os == 'linux'
lockfile += '/var/lock/netatalk'
if 'systemd' in init_style
lockfile = join_paths('/run', runtimedir, 'netatalk.pid')
else
lockfile += '/var/lock/netatalk'
endif
else
lockfile += '/var/spool/locks/netatalk'
endif
Expand Down Expand Up @@ -1894,52 +1963,6 @@ if threads.found()
endif
endif

#
# Check for optional initscript install
#

init_style = get_option('with-init-style')
init_dirs = []
init_style_auto = false
init_cmd = ''

if 'auto' in init_style
init_style_auto = true
if host_os == 'linux'
if linux_distro in ['arch', 'centos', 'debian', 'fedora', 'rhel', 'suse', 'ubuntu']
init_style = ['systemd']
init_cmd = 'systemctl'
elif linux_distro in ['alpine', 'gentoo']
init_style = ['openrc']
init_cmd = 'rc-service'
endif
elif host_os == 'freebsd'
init_style = ['freebsd']
elif host_os == 'netbsd'
init_style = ['netbsd']
init_cmd = 'service'
elif host_os == 'openbsd'
init_style = ['openbsd']
init_cmd = 'rcctl'
elif host_os == 'darwin'
init_style = ['macos-launchd']
elif host_os == 'sunos'
init_style = ['solaris']
init_cmd = 'svcadm'
else
init_style = ['none']
endif
endif

if init_cmd != ''
init_program = find_program(init_cmd, required: not init_style_auto)
if not init_program.found()
warning(init_cmd + ' not found, defaulting to no init scripts')
init_style = ['none']
init_cmd = ''
endif
endif

#
# Check for cracklib support
#
Expand Down Expand Up @@ -2152,6 +2175,7 @@ cdata.set('libdir', libdir)
cdata.set('includedir', includedir)
cdata.set('localstatedir', localstatedir)
cdata.set('lockfile_path', lockfile_path)
cdata.set('runtimedir', runtimedir)
cdata.set('netatalk_version', netatalk_version)
cdata.set('pkgconfdir', pkgconfdir)
cdata.set('prefix', prefix)
Expand Down
6 changes: 6 additions & 0 deletions meson_options.txt
Original file line number Diff line number Diff line change
Expand Up @@ -279,6 +279,12 @@ option(
value: '',
description: 'Set path to Netatalk lockfile',
)
option(
'with-runtime-dir',
type: 'string',
value: '',
description: 'Systemd directory name of the runtime subfolder. Name must be relative and must not include /run or /var/run.',
)
option(
'with-pam-path',
type: 'string',
Expand Down

0 comments on commit e7b75eb

Please sign in to comment.