Skip to content

Commit 6b6fd1f

Browse files
singular0rdmark
authored andcommitted
Default to no init scripts if service management cmd not found #1743
1 parent a39f675 commit 6b6fd1f

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

meson.build

+17
Original file line numberDiff line numberDiff line change
@@ -1900,29 +1900,46 @@ endif
19001900

19011901
init_style = get_option('with-init-style')
19021902
init_dirs = []
1903+
init_style_auto = false
1904+
init_cmd = ''
19031905

19041906
if 'auto' in init_style
1907+
init_style_auto = true
19051908
if host_os == 'linux'
19061909
if linux_distro in ['arch', 'centos', 'debian', 'fedora', 'rhel', 'suse', 'ubuntu']
19071910
init_style = ['systemd']
1911+
init_cmd = 'systemctl'
19081912
elif linux_distro in ['alpine', 'gentoo']
19091913
init_style = ['openrc']
1914+
init_cmd = 'rc-service'
19101915
endif
19111916
elif host_os == 'freebsd'
19121917
init_style = ['freebsd']
19131918
elif host_os == 'netbsd'
19141919
init_style = ['netbsd']
1920+
init_cmd = 'service'
19151921
elif host_os == 'openbsd'
19161922
init_style = ['openbsd']
1923+
init_cmd = 'rcctl'
19171924
elif host_os == 'darwin'
19181925
init_style = ['macos-launchd']
19191926
elif host_os == 'sunos'
19201927
init_style = ['solaris']
1928+
init_cmd = 'svcadm'
19211929
else
19221930
init_style = ['none']
19231931
endif
19241932
endif
19251933

1934+
if init_cmd != ''
1935+
init_program = find_program(init_cmd, required: not init_style_auto)
1936+
if not init_program.found()
1937+
warning(init_cmd + ' not found, defaulting to no init scripts')
1938+
init_style = ['none']
1939+
init_cmd = ''
1940+
endif
1941+
endif
1942+
19261943
#
19271944
# Check for cracklib support
19281945
#

0 commit comments

Comments
 (0)