diskimage-builder/diskimage_builder/elements/dib-init-system/dib-init-system
Andreas Florath 20389d755f Fix dib-init-system for Debian Jessie and Debian Stretch
On Debian Jessie and Debian Stretch systemctl is in /bin.
If the package systemd-sysv is not installed the script
dib-init-system did not find the init system.
This patch fixes the problem: it also looks in /bin
for systemctl and if found decides for systemd.

Change-Id: I5a18052a070bad5e16b14672237a1e2b38513949
Signed-off-by: Andreas Florath <andreas@florath.net>
2017-03-11 14:04:13 +00:00

32 lines
666 B
Bash
Executable File

#!/bin/bash
if [ ${DIB_DEBUG_TRACE:-0} -gt 0 ]; then
set -x
fi
set -eu
set -o pipefail
# Debian Jessie and Debian Stretch use /bin/systemctl.
# (/sbin/init is only available if systemd-sysv is installed.)
if [ -f /usr/bin/systemctl -o -f /bin/systemctl ]; then
echo "systemd"
elif [[ -f /sbin/initctl ]]; then
echo "upstart"
elif [[ -f /etc/gentoo-release ]]; then
if [[ "${GENTOO_PROFILE}" =~ systemd ]]; then
echo "systemd"
else
echo "openrc"
fi
elif [[ -f /sbin/init ]]; then
if [[ -f /bin/systemd ]]; then
echo "systemd"
else
echo "sysv"
fi
else
echo "Unknown init system"
exit 1
fi