2021-10-20 23:06:54 +08:00
|
|
|
#!/bin/bash
|
2021-03-30 06:12:30 +08:00
|
|
|
set -e
|
|
|
|
|
2021-10-20 23:06:54 +08:00
|
|
|
if [ "$EUID" -ne 0 ]; then
|
|
|
|
echo "This script must be run as root"
|
2021-06-03 12:55:39 +08:00
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2021-03-30 19:57:51 +08:00
|
|
|
[ -z "$KEY" ] && KEY=nokey;
|
2021-10-20 23:06:54 +08:00
|
|
|
[ -z "$VERSION" ] && echo "no \$VERSION provided, fallback to latest" && VERSION=latest;
|
2021-03-30 06:12:30 +08:00
|
|
|
|
2021-10-20 23:06:54 +08:00
|
|
|
dist=netclient
|
|
|
|
|
2021-10-21 00:29:59 +08:00
|
|
|
echo "OS Version = $(uname)"
|
2021-10-20 23:06:54 +08:00
|
|
|
echo "Netclient Version = $VERSION"
|
|
|
|
|
2021-10-21 00:29:59 +08:00
|
|
|
if [[ "$(uname)" == "Linux"* ]]; then
|
2021-10-20 23:06:54 +08:00
|
|
|
arch=$(uname -i)
|
|
|
|
echo "CPU ARCH = $arch"
|
|
|
|
if [ "$arch" == 'x86_64' ];
|
|
|
|
then
|
|
|
|
dist=netclient
|
|
|
|
fi
|
|
|
|
if [ "$arch" == 'x86_32' ];
|
|
|
|
then
|
|
|
|
dist=netclient-32
|
|
|
|
fi
|
|
|
|
if [ "$arch" == 'armv*' ];
|
|
|
|
then
|
|
|
|
dist=netclient-arm64
|
|
|
|
fi
|
2021-10-21 00:29:59 +08:00
|
|
|
elif [[ "$(uname)" == "Darwin"* ]]; then
|
2021-10-20 23:06:54 +08:00
|
|
|
dist=netclient-darwin
|
|
|
|
fi
|
|
|
|
|
|
|
|
echo "Binary = $dist"
|
|
|
|
|
|
|
|
wget -O netclient https://github.com/gravitl/netmaker/releases/download/$VERSION/netclient
|
2021-03-30 06:12:30 +08:00
|
|
|
chmod +x netclient
|
2021-06-01 06:05:48 +08:00
|
|
|
sudo ./netclient join -t $KEY
|
2021-03-30 06:12:30 +08:00
|
|
|
rm -f netclient
|