2020-09-22 23:10:16 +01:00
|
|
|
#!/bin/bash
|
2020-09-23 20:22:00 +01:00
|
|
|
# Check if golang exists by the output of "go version"
|
2020-09-22 23:10:16 +01:00
|
|
|
if [ "$(go version | head -c 13)" == "go version go" ]; then
|
|
|
|
echo "Assuming go is installed"
|
2021-03-19 10:03:39 +00:00
|
|
|
shouldbuild="neigh"
|
2020-09-23 20:22:00 +01:00
|
|
|
# Check location for simple vpn binary
|
2020-09-22 23:10:16 +01:00
|
|
|
if [ -f /usr/bin/simple-vpn ]; then
|
|
|
|
echo "Found \"/usr/bin/simple-vpn\" assuming it is installed correctly"
|
2021-03-19 10:03:39 +00:00
|
|
|
echo "Run this script with force as a first argument to force a re-install"
|
2020-09-22 23:10:16 +01:00
|
|
|
else
|
2021-03-19 10:03:39 +00:00
|
|
|
shouldbuild="ye"
|
|
|
|
fi
|
|
|
|
# Look for an argument to force simple vpn re-install
|
|
|
|
if [ "$1" = "force" ]; then
|
|
|
|
shouldbuild="ye"
|
|
|
|
echo "Install enforced!"
|
|
|
|
fi
|
|
|
|
if [ "$shouldbuild" = "ye" ]; then
|
|
|
|
# Check for git repo existence if forcing re-install and delete if it does
|
|
|
|
if [ -d simple-vpn ]; then
|
|
|
|
echo "Found previous simple-vpn git download in working directory:"
|
|
|
|
echo "Deleting!"
|
|
|
|
rm -f -R simple-vpn
|
|
|
|
fi
|
2020-09-23 20:22:00 +01:00
|
|
|
# Clone github repo
|
2020-09-22 23:10:16 +01:00
|
|
|
echo "Cloning simple-vpn"
|
2020-09-23 20:22:00 +01:00
|
|
|
git clone https://codehub.onpointcoding.net/sean/simple-vpn.git
|
2020-09-22 23:10:16 +01:00
|
|
|
cd simple-vpn
|
2020-09-23 20:22:00 +01:00
|
|
|
|
|
|
|
# Build and copy binary to bin directory
|
2020-09-22 23:10:16 +01:00
|
|
|
echo "Installing simple-vpn"
|
|
|
|
go build
|
2021-03-19 18:52:32 +00:00
|
|
|
sudo cp ./simple-vpn /usr/bin/
|
2020-09-22 23:10:16 +01:00
|
|
|
cd ..
|
2020-09-23 20:22:00 +01:00
|
|
|
|
|
|
|
# Remove repository
|
2020-09-22 23:10:16 +01:00
|
|
|
echo "Cleaning up"
|
|
|
|
rm simple-vpn -rf
|
|
|
|
echo "Components installed..."
|
|
|
|
fi
|
|
|
|
else
|
|
|
|
echo "Please install golang before continuing"
|
|
|
|
exit
|
|
|
|
fi
|