diff --git a/README.md b/README.md index 9de3ec4..f896983 100644 --- a/README.md +++ b/README.md @@ -64,8 +64,8 @@ This will build and import the distro. ```sh git clone https://github.com/sakai135/wsl-vpnkit.git cd wsl-vpnkit/ - -./distro/test.sh +./build.sh +./test.sh ``` ## Using `wsl-vpnkit` as a standalone script diff --git a/build.sh b/build.sh new file mode 100755 index 0000000..76c494e --- /dev/null +++ b/build.sh @@ -0,0 +1,20 @@ +#! /bin/sh -xe + +# run from repo root +# ./build.sh + +USERPROFILE="$(powershell.exe -c 'Write-Host -NoNewline $env:USERPROFILE')" +DUMP=wsl-vpnkit.tar.gz +TAG_NAME=wslvpnkit + +# build +docker build -t $TAG_NAME -f ./distro/Dockerfile . +CONTAINER_ID=$(docker create $TAG_NAME) +docker export $CONTAINER_ID | gzip > $DUMP +docker container rm $CONTAINER_ID +ls -la $DUMP + +# reinstall +wsl.exe --unregister wsl-vpnkit || : +wsl.exe --import wsl-vpnkit "$USERPROFILE\\wsl-vpnkit" $DUMP --version 2 +rm $DUMP diff --git a/distro/test.sh b/test.sh similarity index 72% rename from distro/test.sh rename to test.sh index 0e16877..95e1d60 100755 --- a/distro/test.sh +++ b/test.sh @@ -1,32 +1,19 @@ #! /bin/sh -xe -# run from repo root -# ./distro/test.sh - -USERPROFILE="$(powershell.exe -c 'Write-Host -NoNewline $env:USERPROFILE')" -DUMP=wsl-vpnkit.tar.gz -TAG_NAME=wslvpnkit - -# build -docker build -t $TAG_NAME -f ./distro/Dockerfile . -CONTAINER_ID=$(docker create $TAG_NAME) -docker export $CONTAINER_ID | gzip > $DUMP -docker container rm $CONTAINER_ID -ls -la $DUMP - -# reinstall -wsl.exe --unregister wsl-vpnkit || : -wsl.exe --import wsl-vpnkit "$USERPROFILE\\wsl-vpnkit" $DUMP --version 2 -rm $DUMP +# 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 || \ + wsl.exe -t wsl-vpnkit +fi # tests -for debug_value in '1' ''; do +for debug_value in '1' '2' ''; do if [ -n "${debug_value}" ]; then debug_str="DEBUG=${debug_value}" else debug_str="" fi - echo "####### Test Round with debug_str [${debug_str}] #######" + echo "####### Test Round with debug_str [${debug_str}] #######" | grep --colour=always . # start service wsl.exe -d wsl-vpnkit ${debug_str} service wsl-vpnkit start @@ -59,4 +46,4 @@ for debug_value in '1' ''; do wsl.exe -d wsl-vpnkit sh -c 'echo 1 | source /etc/profile' done -echo "$0 Finished" \ No newline at end of file +echo "$0 Finished" | grep --colour=always . \ No newline at end of file