From a2a22c4e138398499d649135ccc7c53a3fcf019a Mon Sep 17 00:00:00 2001 From: DL6ER Date: Mon, 23 Dec 2024 09:13:34 +0100 Subject: [PATCH] Exit early when neither service nor systemctl commands are available Signed-off-by: DL6ER --- automated install/basic-install.sh | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/automated install/basic-install.sh b/automated install/basic-install.sh index c5d2ad9c..368fa6c0 100755 --- a/automated install/basic-install.sh +++ b/automated install/basic-install.sh @@ -2328,6 +2328,17 @@ migrate_dnsmasq_configs() { mv /etc/dnsmasq.d/06-rfc6761.conf "${V6_CONF_MIGRATION_DIR}/" 2>/dev/null || true } +# Check for availability of either the "service" or "systemctl" commands +check_service_command() { + # Check for the availability of the "service" command + if ! is_command service && ! is_command systemctl; then + # If neither the "service" nor the "systemctl" command is available, inform the user + printf " %b Neither the service nor the systemctl commands are available\\n" "${CROSS}" + printf " on this machine. This Pi-hole installer cannot continue.\\n" + exit 1 + fi +} + main() { ######## FIRST CHECK ######## # Must be root to install @@ -2376,6 +2387,9 @@ main() { # Check if SELinux is Enforcing and exit before doing anything else checkSelinux + # Check for availability of either the "service" or "systemctl" commands + check_service_command + # Check for supported package managers so that we may install dependencies package_manager_detect