From 9fc9241c47cb0662c88b954fd83cc95f31d155b7 Mon Sep 17 00:00:00 2001 From: Arnie Date: Mon, 27 Aug 2018 08:06:53 +0200 Subject: [PATCH] Update windows startup scripts --- windows/install-docker-in-wsl.sh | 45 ++++++++++++++++++++++++++++++-- 1 file changed, 43 insertions(+), 2 deletions(-) diff --git a/windows/install-docker-in-wsl.sh b/windows/install-docker-in-wsl.sh index 0fe214f..638830a 100755 --- a/windows/install-docker-in-wsl.sh +++ b/windows/install-docker-in-wsl.sh @@ -100,13 +100,39 @@ installRelay() { /usr/local/go/bin/go get -d github.com/jstarks/npiperelay [[ $? -ne 0 ]] && echo "Could not fetch the relay" && return 137 + local diskPath=/mnt/c/Users + + [[ ! -d "${diskPath}" ]] && diskPath=/c/Users + [[ ! -d "${diskPath}" ]] && diskPath=/mnt/d/Users + [[ ! -d "${diskPath}" ]] && diskPath=/d/Users + + if [[ ! -d "${diskPath}" ]]; then + echo "Cannot locate the directory with user accounts [attempted: /mnt/c/Users, /mnt/d/Users, /c/Users, /d/Users" + until [[ -d "${diskPath}" ]] ; do + echo "Please provide a path to the directory:" + read diskPath + done + + fi + + local userPath=${diskPath}/${USER} + + until [[ -d "${userPath}" ]] ; do + local newUser + echo "Path ${userPath} does not exist!" + echo "It seems you are running the shell under different user, please provide a windows username to install the relay under" + read newUser + userPath=${diskPath}/${newUser} + done + echo "Building the relay binary for windows" export GOOS=windows - /usr/local/go/bin/go build -o /mnt/c/Users/${USER}/go/bin/npiperelay.exe github.com/jstarks/npiperelay + /usr/local/go/bin/go build -o "${userPath}/go/bin/npiperelay.exe" github.com/jstarks/npiperelay [[ $? -ne 0 ]] && echo "Could not build the binary" && return 137 echo "Linking the relay binary" - sudo ln -s /mnt/c/Users/${USER}/go/bin/npiperelay.exe /usr/local/bin/npiperelay.exe + [[ -e ${userPath}/go/bin/npiperelay.exe ]] && sudo rm ${userPath}/go/bin/npiperelay.exe + sudo ln -s ${userPath}/go/bin/npiperelay.exe /usr/local/bin/npiperelay.exe [[ $? -ne 0 ]] && echo "Could not link the binary" && return 137 echo "Installing socat" @@ -235,6 +261,21 @@ root = / options = "metadata" EOF + local linkPath=/usr/local/bin/npiperelay.exe + if [[ -e "${linkPath}" ]]; then + local relayPath=$(readlink $linkPath) + + relayPath=${relayPath/\/mnt/} + + until [[ -f "${relayPath}" ]]; do + echo "Cannot find path to the npiperelay. Please provide a path to binary" + read relayPath + done + + echo "Linking relaypath to ${linkPath}" + ln -s ${relayPath} ${linkPath} + fi + [[ $? -ne 0 ]] && return 137 echo "Please restart your computer, after the restart the volumes will be mounted in /c/, /d/, etc. instead of /mnt/c/, /mnt/d/..."