From 191e9863642119a5088124f714bb045de29e3348 Mon Sep 17 00:00:00 2001 From: Tobias Kussel Date: Wed, 22 Feb 2023 15:32:21 +0100 Subject: [PATCH 1/4] Add check for installation in WSL and for systemd --- lib/prepare-system.sh | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/lib/prepare-system.sh b/lib/prepare-system.sh index 2cba2e2..2a4fdae 100755 --- a/lib/prepare-system.sh +++ b/lib/prepare-system.sh @@ -5,6 +5,15 @@ source lib/functions.sh log "INFO" "Preparing your system for bridgehead installation ..." +# Check, if running in WSL +if [[ $(grep -i Microsoft /proc/version) ]]; then + # Check, if systemd is available + if [ ! $(systemctl) ]; then + log "ERROR" "It seems, that you have no active systemd environment in your WSL. Please follow the guide in https://devblogs.microsoft.com/commandline/systemd-support-is-now-available-in-wsl/" + exit 1 + fi +fi + # Create the bridgehead user if id bridgehead &>/dev/null; then log "INFO" "Existing user with id $(id -u bridgehead) will be used by the bridgehead system units." From 4578c77d4bf18d2275d45a94532cdfed04673bb8 Mon Sep 17 00:00:00 2001 From: Tobias Kussel Date: Wed, 22 Feb 2023 15:42:52 +0100 Subject: [PATCH 2/4] Fix systemd check --- lib/prepare-system.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/prepare-system.sh b/lib/prepare-system.sh index 2a4fdae..cfede1e 100755 --- a/lib/prepare-system.sh +++ b/lib/prepare-system.sh @@ -8,7 +8,7 @@ log "INFO" "Preparing your system for bridgehead installation ..." # Check, if running in WSL if [[ $(grep -i Microsoft /proc/version) ]]; then # Check, if systemd is available - if [ ! $(systemctl) ]; then + if [ $(systemctl is-system-running) -eq "offline" ]; then log "ERROR" "It seems, that you have no active systemd environment in your WSL. Please follow the guide in https://devblogs.microsoft.com/commandline/systemd-support-is-now-available-in-wsl/" exit 1 fi From 7a350a8c9b2e3c1d5a8c3a56d0e7958e468ea39a Mon Sep 17 00:00:00 2001 From: Tobias Kussel Date: Fri, 24 Feb 2023 11:29:06 +0100 Subject: [PATCH 3/4] Fix string comparison in WSL check --- lib/prepare-system.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/prepare-system.sh b/lib/prepare-system.sh index cfede1e..169ad2c 100755 --- a/lib/prepare-system.sh +++ b/lib/prepare-system.sh @@ -8,7 +8,7 @@ log "INFO" "Preparing your system for bridgehead installation ..." # Check, if running in WSL if [[ $(grep -i Microsoft /proc/version) ]]; then # Check, if systemd is available - if [ $(systemctl is-system-running) -eq "offline" ]; then + if [ $(systemctl is-system-running) = "offline" ]; then log "ERROR" "It seems, that you have no active systemd environment in your WSL. Please follow the guide in https://devblogs.microsoft.com/commandline/systemd-support-is-now-available-in-wsl/" exit 1 fi From bfc00b99676ce51c821bd9fd38739ed5e3495843 Mon Sep 17 00:00:00 2001 From: Tobias Kussel Date: Fri, 24 Feb 2023 11:41:05 +0100 Subject: [PATCH 4/4] Prevent variable splitting in wsl check and improve error message --- lib/prepare-system.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/prepare-system.sh b/lib/prepare-system.sh index 169ad2c..7e9f24f 100755 --- a/lib/prepare-system.sh +++ b/lib/prepare-system.sh @@ -8,8 +8,8 @@ log "INFO" "Preparing your system for bridgehead installation ..." # Check, if running in WSL if [[ $(grep -i Microsoft /proc/version) ]]; then # Check, if systemd is available - if [ $(systemctl is-system-running) = "offline" ]; then - log "ERROR" "It seems, that you have no active systemd environment in your WSL. Please follow the guide in https://devblogs.microsoft.com/commandline/systemd-support-is-now-available-in-wsl/" + if [ "$(systemctl is-system-running)" = "offline" ]; then + log "ERROR" "It seems you have no active systemd environment in your WSL environment. Please follow the guide in https://devblogs.microsoft.com/commandline/systemd-support-is-now-available-in-wsl/" exit 1 fi fi