Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add wsl.exe --cd arg #157

Merged
merged 1 commit into from
Nov 15, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,21 +13,21 @@ Download the prebuilt file `wsl-vpnkit.tar.gz` from the [latest release](https:/
```pwsh
# PowerShell
wsl --import wsl-vpnkit $env:USERPROFILE\wsl-vpnkit wsl-vpnkit.tar.gz --version 2
wsl --import wsl-vpnkit --version 2 $env:USERPROFILE\wsl-vpnkit wsl-vpnkit.tar.gz
wsl -d wsl-vpnkit
```

Start `wsl-vpnkit` from your other WSL 2 distros. Add the command to your `.profile` or `.bashrc` to start `wsl-vpnkit` when you open your WSL terminal.

```sh
wsl.exe -d wsl-vpnkit service wsl-vpnkit start
wsl.exe -d wsl-vpnkit --cd /app service wsl-vpnkit start
```

You can also check service status to start service only if needed.

```sh
wsl.exe -d wsl-vpnkit service wsl-vpnkit status >/dev/null || \
wsl.exe -d wsl-vpnkit service wsl-vpnkit start
wsl.exe -d wsl-vpnkit --cd /app service wsl-vpnkit status >/dev/null || \
wsl.exe -d wsl-vpnkit --cd /app service wsl-vpnkit start
```

### Notes
Expand All @@ -43,7 +43,7 @@ To update, unregister the existing distro and import the new version.
# PowerShell
wsl --unregister wsl-vpnkit
wsl --import wsl-vpnkit $env:USERPROFILE\wsl-vpnkit wsl-vpnkit.tar.gz --version 2
wsl --import wsl-vpnkit --version 2 $env:USERPROFILE\wsl-vpnkit wsl-vpnkit.tar.gz
```

### Uninstall
Expand Down Expand Up @@ -109,7 +109,7 @@ For this and other networking considerations when using WSL 2, see [Accessing ne
### Run in foreground

```sh
wsl.exe -d wsl-vpnkit wsl-vpnkit
wsl.exe -d wsl-vpnkit --cd /app wsl-vpnkit
```

### Try shutting down WSL 2 VM to reset
Expand All @@ -127,5 +127,5 @@ If you set DEBUG variable before calling service you can see more debug informat

Example:
```sh
wsl.exe -d wsl-vpnkit DEBUG=1 service wsl-vpnkit restart
wsl.exe -d wsl-vpnkit --cd /app DEBUG=1 service wsl-vpnkit restart
```
2 changes: 1 addition & 1 deletion build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,5 @@ ls -la $DUMP

# reinstall
wsl.exe --unregister wsl-vpnkit || :
wsl.exe --import wsl-vpnkit "$USERPROFILE\\wsl-vpnkit" $DUMP --version 2
wsl.exe --import wsl-vpnkit --version 2 "$USERPROFILE\\wsl-vpnkit" $DUMP
rm $DUMP
10 changes: 5 additions & 5 deletions distro/scripts/startup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,28 +12,28 @@ This distro is only intended for running wsl-vpnkit.
Run the following commands from Windows or other WSL 2 distros to use.
wsl.exe -d $WSL_DISTRO_NAME service wsl-vpnkit stop
wsl.exe -d $WSL_DISTRO_NAME service wsl-vpnkit start
wsl.exe -d $WSL_DISTRO_NAME --cd /app service wsl-vpnkit stop
wsl.exe -d $WSL_DISTRO_NAME --cd /app service wsl-vpnkit start
The following file will be copied if it does not already exist.
$USERPROFILE/wsl-vpnkit/wsl-gvproxy.exe
Logs for wsl-vpnkit can be viewed here.
wsl.exe -d $WSL_DISTRO_NAME tail -f $LOG_PATH
wsl.exe -d $WSL_DISTRO_NAME --cd /app tail -f $LOG_PATH
To see only the most recent logs
wsl.exe -d $WSL_DISTRO_NAME sh -c \"tac $LOG_PATH | awk '{print}; /starting wsl-vpnkit/{exit}' | tac\"
wsl.exe -d $WSL_DISTRO_NAME --cd /app sh -c \"tac $LOG_PATH | awk '{print}; /starting wsl-vpnkit/{exit}' | tac\"
Config for wsl-vpnkit can be edited here.
$USERPROFILE/wsl-vpnkit/wsl-vpnkit.conf
Run the following command to see the default values.
wsl.exe -d $WSL_DISTRO_NAME cat /app/defaults.conf
wsl.exe -d $WSL_DISTRO_NAME --cd /app cat /app/defaults.conf
Press [enter] key to continue...
"
Expand Down
20 changes: 10 additions & 10 deletions test.sh
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
#! /bin/sh -xe

# ensuring distro is stopped before running tests
if wsl.exe -d wsl-vpnkit service wsl-vpnkit status; then
wsl.exe -d wsl-vpnkit service wsl-vpnkit stop || \
if wsl.exe -d wsl-vpnkit --cd /app service wsl-vpnkit status; then
wsl.exe -d wsl-vpnkit --cd /app service wsl-vpnkit stop || \
wsl.exe -t wsl-vpnkit
fi

Expand All @@ -16,13 +16,13 @@ for debug_value in '1' '2' ''; do
echo "####### Test Round with debug_str [${debug_str}] #######" | grep --colour=always .

# start service
wsl.exe -d wsl-vpnkit ${debug_str} service wsl-vpnkit start
output=$(wsl.exe -d wsl-vpnkit ${debug_str} service wsl-vpnkit status)
wsl.exe -d wsl-vpnkit --cd /app ${debug_str} service wsl-vpnkit start
output=$(wsl.exe -d wsl-vpnkit --cd /app ${debug_str} service wsl-vpnkit status)
echo "$output" | grep --colour=always "Service wsl-vpnkit is running"

# check latest log
sleep 5
output=$(wsl.exe -d wsl-vpnkit sh -c "tac /var/log/wsl-vpnkit.log | awk '{print}; /starting wsl-vpnkit/{exit}' | tac")
output=$(wsl.exe -d wsl-vpnkit --cd /app sh -c "tac /var/log/wsl-vpnkit.log | awk '{print}; /starting wsl-vpnkit/{exit}' | tac")

( set +x # avoid clutter during output checks
# check for working ping
Expand All @@ -33,17 +33,17 @@ for debug_value in '1' '2' ''; do
)

# restart service
wsl.exe -d wsl-vpnkit ${debug_str} service wsl-vpnkit restart
output=$(wsl.exe -d wsl-vpnkit ${debug_str} service wsl-vpnkit status)
wsl.exe -d wsl-vpnkit --cd /app ${debug_str} service wsl-vpnkit restart
output=$(wsl.exe -d wsl-vpnkit --cd /app ${debug_str} service wsl-vpnkit status)
echo "$output" | grep --colour=always "Service wsl-vpnkit is running"

# stop service
wsl.exe -d wsl-vpnkit ${debug_str} service wsl-vpnkit stop
output=$(wsl.exe -d wsl-vpnkit ${debug_str} service wsl-vpnkit status)||echo "ignoring exit code"
wsl.exe -d wsl-vpnkit --cd /app ${debug_str} service wsl-vpnkit stop
output=$(wsl.exe -d wsl-vpnkit --cd /app ${debug_str} service wsl-vpnkit status)||echo "ignoring exit code"
echo "$output" | grep --colour=always "Service wsl-vpnkit is not running"

# check welcome screen
wsl.exe -d wsl-vpnkit sh -c 'echo 1 | source /etc/profile'
wsl.exe -d wsl-vpnkit --cd /app sh -c 'echo 1 | source /etc/profile'
done

echo "$0 Finished" | grep --colour=always .