diff --git a/elements/base/dib-init-system b/elements/base/dib-init-system new file mode 100755 index 000000000..88cf5faeb --- /dev/null +++ b/elements/base/dib-init-system @@ -0,0 +1,18 @@ +#!/bin/bash + +set -eu + +if [ -f /sbin/initctl ]; then + echo "upstart" +elif [ -f /usr/bin/systemctl ]; then + echo "systemd" +elif [ -f /sbin/init ]; then + if [ -f /bin/systemd ]; then + echo "systemd" + else + echo "sysv" + fi +else + echo "Unknown init system" + exit 1 +fi diff --git a/elements/base/environment.d/10-dib-init-system.bash b/elements/base/environment.d/10-dib-init-system.bash new file mode 100644 index 000000000..f264a23af --- /dev/null +++ b/elements/base/environment.d/10-dib-init-system.bash @@ -0,0 +1 @@ +export DIB_INIT_SYSTEM=$(dib-init-system) diff --git a/elements/base/pre-install.d/04-dib-init-system b/elements/base/pre-install.d/04-dib-init-system new file mode 100755 index 000000000..54ea25876 --- /dev/null +++ b/elements/base/pre-install.d/04-dib-init-system @@ -0,0 +1,5 @@ +#!/bin/bash + +set -e + +install -m 0755 -o root -g root $(dirname $0)/../dib-init-system /usr/bin/