From cc3f5f29aeb396bd40db6365a3e7b0326d107856 Mon Sep 17 00:00:00 2001 From: Abhijay jain Date: Mon, 22 May 2023 01:41:11 +0530 Subject: [PATCH] (Fix) : Resolved spaces error in WSL login Signed-off-by: Abhijay jain --- assets/scripts/check-login.sh | 6 +++--- assets/scripts/configure-microk8s-windows.ps1 | 13 +++++++++++-- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/assets/scripts/check-login.sh b/assets/scripts/check-login.sh index 4b844282..700e9d24 100644 --- a/assets/scripts/check-login.sh +++ b/assets/scripts/check-login.sh @@ -4,7 +4,7 @@ # Parameters #=========== -PASSWORD=$1 +PASSWORD="$1" #====== # Login @@ -12,9 +12,9 @@ PASSWORD=$1 LOGIN=$(echo "$PASSWORD" | sudo -S echo "User logged in") if [[ $LOGIN == *"User logged in"* ]]; then - echo "user logged in" + echo "User logged in" exit 0 else - echo "user not logged in" + echo "User not logged in" exit 1 fi diff --git a/assets/scripts/configure-microk8s-windows.ps1 b/assets/scripts/configure-microk8s-windows.ps1 index 7b0c70ff..b5ca8936 100644 --- a/assets/scripts/configure-microk8s-windows.ps1 +++ b/assets/scripts/configure-microk8s-windows.ps1 @@ -115,9 +115,18 @@ else { # WSL Login #========== -wsl bash -ic "`"$SCRIPTS_FOLDER/check-login.sh`" `"$PASSWORD`""; +$checkLoginScript = "$SCRIPTS_FOLDER/check-login.sh" +$checkLoginScriptPath = "`"$checkLoginScript`" `"$PASSWORD`"" -checkExitCode; +$loginStatus = wsl bash -ic "$checkLoginScriptPath" + +if ($loginStatus -like '*User logged in*') { + Write-Host "User logged in" +} +else { + Write-Host "User not logged in" + exit 1 +} #====================== # Enable systemd in WSL