From c3ebd755b9e0b042b06ade6daaeacbf39a86895e Mon Sep 17 00:00:00 2001 From: IceCodeNew <32576256+IceCodeNew@users.noreply.github.com> Date: Fri, 25 Sep 2020 14:29:53 +0800 Subject: [PATCH] Introduce a more convenient way to detect systemd Refer: https://manpages.ubuntu.com/manpages/focal/en/man3/sd_booted.3.html --- install-release.sh | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/install-release.sh b/install-release.sh index 4aec23e..96597c7 100644 --- a/install-release.sh +++ b/install-release.sh @@ -93,7 +93,14 @@ identify_the_operating_system_and_architecture() { echo "error: Don't use outdated Linux distributions." exit 1 fi - if [[ -z "$(ls -l /sbin/init | grep systemd)" ]]; then + # Do not combine this judgment condition with the following judgment condition. + ## Be aware of Linux distribution like Gentoo, which kernel supports switch between Systemd and OpenRC. + ### Refer: https://github.com/v2fly/fhs-install-v2ray/issues/84#issuecomment-688574989 + if [[ -f /.dockerenv ]] || grep -q 'docker\|lxc' /proc/1/cgroup && [[ "$(type -P systemctl)" ]]; then + true + elif [[ -d /run/systemd/system ]] || grep -q systemd <(ls -l /sbin/init); then + true + else echo "error: Only Linux distributions using systemd are supported." exit 1 fi