wsl poweroff

This commit is contained in:
2023-07-13 12:48:39 +00:00
parent 33bd79b837
commit 7e17e3f5f5

View File

@@ -452,16 +452,29 @@ if [ "$1" == "remove" ]; then
exit;
fi; # else run install
if [ ! -f /etc/wsl.conf ]; then
$SUDO_CMD touch /etc/wsl.conf;
fi
SYSTEM_SETTINGS="$(grep -Pzow '\[boot\]\nsystemd\=true' /etc/wsl.conf > /dev/null)";
if [ "$SYSTEM_SETTINGS" == "" ]; then
echo "[boot]
# running on WSL
if [ -n "$WSL_DISTRO_NAME" ]; then
if [ ! -f /etc/wsl.conf ]; then
$SUDO_CMD touch /etc/wsl.conf;
fi
SYSTEM_SETTINGS="$(grep -Pzow '\[boot\]\nsystemd\=true' /etc/wsl.conf > /dev/null)";
if [ "$SYSTEM_SETTINGS" == "" ]; then
echo "[boot]
systemd=true" | $SUDO_CMD tee /etc/wsl.conf;
echo "Not corresponding wsl configuration found, modified and need a WSL system restart from Windows terminal";
fi
echo "Not a corresponding wsl configuration has found, conf was modified and need a WSL system restart from Windows terminal";
echo "Do you want to restart the $WSL_DISTRO_NAME system now? (Y/n)";
read -r ANSWER;
if [ "$ANSWER" == "y" ] || [ "$ANSWER" == "Y" ] || [ "$ANSWER" == "" ] ; then
echo "Exiting. Please join again using wsl command."
$SUDO_CMD poweroff -f;
else
echo "Bye.";
exit;
fi;
fi
fi;
echo "Would you like to install/update docker? (y/N)";
read -r ANSWER;