Initial commit

This commit is contained in:
2026-09-05 02:13:35 +08:00
commit b85e5c4a8b
6 changed files with 91 additions and 0 deletions
Executable
+7
View File
@@ -0,0 +1,7 @@
#!/bin/bash
# returns if windows is mounted
MOUNTED="$(mount | egrep -w '^C:\\')"
if [ -z "$MOUNTED" ]; then
exit 1
fi
echo "$MOUNTED" | sed -n 's/^.* on \(.*\) type [a-zA-Z0-9_.]\+ (.*)$/\1/p'
+8
View File
@@ -0,0 +1,8 @@
#!/bin/bash
# returns succesful when wsl interop is ready
shopt -s nullglob
if [ -f /proc/sys/fs/binfmt_misc/WSLInterop ] && \
sockets=(/run/WSL/*_interop) && [ -S "${sockets[0]:-}" ]; then
exit 0
fi
exit 1
+17
View File
@@ -0,0 +1,17 @@
#!/bin/bash
# wait until wsl environment is ready
APP_DIR="$(dirname "$0")"
WSL_INTEROP_READY="$APP_DIR/wsl-interop-ready"
INTERVAL=0.5
TIMEOUT=$1
SECONDS=0
until $WSL_INTEROP_READY; do
if [ "$TIMEOUT" ] && (( SECONDS >= "$TIMEOUT" )); then
echo "Timeout waiting for WSL socket dir" >&2
exit 1
fi
sleep $INTERVAL
done
Executable
+33
View File
@@ -0,0 +1,33 @@
#!/bin/bash
# mounts a windows VHD in wsl
APP_DIR="$(dirname "$0")"
WINDOWS_MOUNT="$APP_DIR/windows-mount"
WSL_PATH="$APP_DIR/wsl-path"
WSL_INTEROP_READY="$APP_DIR/wsl-interop-ready"
SLEEP_INTERVAL=0.5
DRIVE="$1"
DISK_LABEL="$2"
DISK_PATH="/dev/disk/by-label/$DISK_LABEL"
if ! $WINDOWS_MOUNT >/dev/null; then
echo "Error: Windows not mounted" >&2
exit 1
fi
if ! $WSL_INTEROP_READY; then
echo "Error: WSL Interop not ready" >&2
exit 1
fi
WSL="$($WSL_PATH)"
if ! [ -e "$DISK_PATH" ]; then
$WSL --mount --bare --vhd "$DRIVE"
# poll until the block device node appears or task times out
until [ -L "$DISK_PATH" ] && [ -b "$DISK_PATH" ]; do
sleep "$SLEEP_INTERVAL"
done
fi
exit 0
Executable
+6
View File
@@ -0,0 +1,6 @@
#!/bin/bash
# outputs the wsl.exe path by constructing the C:\Windows\System32 mountpoint
APP_DIR="$(dirname "$0")"
WINDOWS_MOUNT="$APP_DIR/windows-mount"
WINDOWS="$($WINDOWS_MOUNT)" || { echo Windows not mounted; exit 1; }
echo "$WINDOWS/Windows/System32/wsl.exe"
Executable
+20
View File
@@ -0,0 +1,20 @@
#!/bin/bash
APP_DIR="$(dirname "$0")"
WINDOWS_MOUNT="$APP_DIR/windows-mount"
WSL_INTEROP_READY="$APP_DIR/wsl-interop-ready"
WSL_PATH="$APP_DIR/wsl-path"
DRIVE="$1"
if ! $WINDOWS_MOUNT >/dev/null; then
echo "Error: Windows not mounted" >&2
exit 1
fi
if ! $WSL_INTEROP_READY; then
echo "Error: WSL Interop not found in /run/WSL" >&2
exit 1
fi
WSL="$($WSL_PATH)"
$WSL --unmount "$DRIVE"