Provide a way of determining init system used
dib-init-system script is installed into $PATH. Called without arguments it will print the name of init system used to stdout. Additionally, set DIB_INIT_SYSTEM environment variable to the init system used. Tested on ubuntu+upstart, centos+upstart, fedora+systemd, debian+sysv. Closes-Bug: #1251610 Change-Id: I29668079091f6060dab66d8259890384d3bbd653
This commit is contained in:
parent
35830cc57c
commit
b01c73aadc
18
elements/base/dib-init-system
Executable file
18
elements/base/dib-init-system
Executable file
@ -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
|
1
elements/base/environment.d/10-dib-init-system.bash
Normal file
1
elements/base/environment.d/10-dib-init-system.bash
Normal file
@ -0,0 +1 @@
|
|||||||
|
export DIB_INIT_SYSTEM=$(dib-init-system)
|
5
elements/base/pre-install.d/04-dib-init-system
Executable file
5
elements/base/pre-install.d/04-dib-init-system
Executable file
@ -0,0 +1,5 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
set -e
|
||||||
|
|
||||||
|
install -m 0755 -o root -g root $(dirname $0)/../dib-init-system /usr/bin/
|
Loading…
Reference in New Issue
Block a user