Update windows startup scripts

This commit is contained in:
Arnie 2018-08-27 08:06:53 +02:00
parent 1b5319b3fa
commit 9fc9241c47

View File

@ -100,13 +100,39 @@ installRelay() {
/usr/local/go/bin/go get -d github.com/jstarks/npiperelay /usr/local/go/bin/go get -d github.com/jstarks/npiperelay
[[ $? -ne 0 ]] && echo "Could not fetch the relay" && return 137 [[ $? -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" echo "Building the relay binary for windows"
export GOOS=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 [[ $? -ne 0 ]] && echo "Could not build the binary" && return 137
echo "Linking the relay binary" 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 [[ $? -ne 0 ]] && echo "Could not link the binary" && return 137
echo "Installing socat" echo "Installing socat"
@ -235,6 +261,21 @@ root = /
options = "metadata" options = "metadata"
EOF 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 [[ $? -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/..." echo "Please restart your computer, after the restart the volumes will be mounted in /c/, /d/, etc. instead of /mnt/c/, /mnt/d/..."