Allow init package detection to fail.

As the init system isn't necessarily shipped in a package (dpkg and
rpm fail), then use the PID 1 file path to assume the init system.
This commit is contained in:
Kyle Robbertze 2019-01-10 15:29:04 +02:00
parent 1ab5a42de2
commit 916cc35058
1 changed files with 7 additions and 11 deletions

18
install
View File

@ -149,18 +149,14 @@ function systemInitDetect() {
# returns '/sbin/init' (Debian Wheezy & Ubuntu Trusty) # returns '/sbin/init' (Debian Wheezy & Ubuntu Trusty)
# returns '(/usr)?/lib/systemd/systemd' (Debian Stretch, Debian Jessie, Debian Buster, Ubuntu Xenial, CentOS 7) # returns '(/usr)?/lib/systemd/systemd' (Debian Stretch, Debian Jessie, Debian Buster, Ubuntu Xenial, CentOS 7)
verbose "Detected path to PID=1 process: $pid_1_path" verbose "Detected path to PID=1 process: $pid_1_path"
# Get package of PID=1 path as it identifies the init system # Get package of PID=1 path as it identifies the init system.
if $if_debian_buster; then # Allow this to fail, at least then the init system can be guessed from the
# /usr/lib/systemd/systemd is provided by the base system in Debian Buster, so # PID 1 executable alone
# dpkg -S /usr/lib/systemd returns an error - no path found matching pattern pid_1_package=$(dpkg -S $pid_1_path 2>/dev/null ||
# This is a work around to avoid failing on package detection rpm --qf '%{name}\n' -qf $pid_1_path 2>/dev/null ||
pid_1_package=systemd echo "unknown")
else
pid_1_package=$(dpkg -S $pid_1_path 2>/dev/null ||
rpm --qf '%{name}\n' -qf $pid_1_path 2>/dev/null)
fi
verbose "Detected package name for PID=1 process: $pid_1_package" verbose "Detected package name for PID=1 process: $pid_1_package"
case "${pid_1_package-$pid_1_path}" in case "${pid_1_package:$pid_1_path}" in
*systemd*) has_systemd_init=true; verbose "Detected init system type: systemd" ;; *systemd*) has_systemd_init=true; verbose "Detected init system type: systemd" ;;
*upstart*) has_upstart_init=true; verbose "Detected init system type: Upstart" ;; *upstart*) has_upstart_init=true; verbose "Detected init system type: Upstart" ;;
*sysvinit*) has_systemv_init=true; verbose "Detected init system type: System V" ;; *sysvinit*) has_systemv_init=true; verbose "Detected init system type: System V" ;;