Ensures this script only runs in WSL
To prevent issues with desktop or server.
This commit is contained in:
parent
5331268600
commit
09bc1b7386
|
@ -6,6 +6,17 @@
|
|||
|
||||
START=$(date +%s.%N)
|
||||
|
||||
function exit_if_not_wsl2() {
|
||||
# WSLInterop ensures we are under WSL (either 1 or 2).
|
||||
# config.gz ensures we have a kernel. WSL 1 does not have one.
|
||||
# grep'ing /proc/version for 'WSL2' would work, but users can change that
|
||||
# when compiling their own kernel.
|
||||
if ! [[ -f "/proc/sys/fs/binfmt_misc/WSLInterop" && -f "/proc/config.gz" ]]; then
|
||||
echo "WSL 2 not detected. Exiting."
|
||||
exit 125
|
||||
fi
|
||||
}
|
||||
|
||||
# ensure_dir_exists calls `mkdir -p` if the given path is not a directory.
|
||||
# This speeds up execution time by avoiding unnecessary calls to mkdir.
|
||||
#
|
||||
|
@ -27,6 +38,9 @@ function wait_for_async_execs() {
|
|||
done
|
||||
}
|
||||
|
||||
# Proceed only if in WSL 2:
|
||||
exit_if_not_wsl2
|
||||
|
||||
# shellcheck source=/dev/null
|
||||
source "$SNAP_USER_DATA/.last_revision" 2>/dev/null || true
|
||||
if [ "$SNAP_DESKTOP_LAST_REVISION" = "$SNAP_REVISION" ]; then
|
||||
|
|
Loading…
Reference in New Issue