|
@@ -1,5 +1,44 @@
|
|
#!/bin/bash
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
+# setup_netclient - installs netclient locally
|
|
|
|
+setup_netclient() {
|
|
|
|
+ if [ -f /etc/debian_version ]; then
|
|
|
|
+ curl -sL 'https://apt.netmaker.org/gpg.key' | sudo tee /etc/apt/trusted.gpg.d/netclient.asc
|
|
|
|
+ curl -sL 'https://apt.netmaker.org/debian.deb.txt' | sudo tee /etc/apt/sources.list.d/netclient.list
|
|
|
|
+ sudo apt update
|
|
|
|
+ sudo apt install netclient
|
|
|
|
+ elif [ -f /etc/centos-release ]; then
|
|
|
|
+ curl -sL 'https://rpm.netmaker.org/gpg.key' | sudo tee /tmp/gpg.key
|
|
|
|
+ curl -sL 'https://rpm.netmaker.org/netclient-repo' | sudo tee /etc/yum.repos.d/netclient.repo
|
|
|
|
+ sudo rpm --import /tmp/gpg.key
|
|
|
|
+ sudo dnf check-update
|
|
|
|
+ sudo dnf install netclient
|
|
|
|
+ elif [ -f /etc/fedora-release ]; then
|
|
|
|
+ curl -sL 'https://rpm.netmaker.org/gpg.key' | sudo tee /tmp/gpg.key
|
|
|
|
+ curl -sL 'https://rpm.netmaker.org/netclient-repo' | sudo tee /etc/yum.repos.d/netclient.repo
|
|
|
|
+ sudo rpm --import /tmp/gpg.key
|
|
|
|
+ sudo dnf check-update
|
|
|
|
+ sudo dnf install netclient
|
|
|
|
+ elif [ -f /etc/redhat-release ]; then
|
|
|
|
+ curl -sL 'https://rpm.netmaker.org/gpg.key' | sudo tee /tmp/gpg.key
|
|
|
|
+ curl -sL 'https://rpm.netmaker.org/netclient-repo' | sudo tee /etc/yum.repos.d/netclient.repo
|
|
|
|
+ sudo rpm --import /tmp/gpg.key
|
|
|
|
+ sudo dnf check-update(
|
|
|
|
+ sudo dnf install netclient
|
|
|
|
+ elif [ -f /etc/arch-release ]; then
|
|
|
|
+ yay -S netclient
|
|
|
|
+ else
|
|
|
|
+ echo "OS not supported for automatic install"
|
|
|
|
+ exit 1
|
|
|
|
+ fi
|
|
|
|
+
|
|
|
|
+ if [ -z "${install_cmd}" ]; then
|
|
|
|
+ echo "OS unsupported for automatic dependency install"
|
|
|
|
+ exit 1
|
|
|
|
+ fi
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+
|
|
cat << "EOF"
|
|
cat << "EOF"
|
|
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
|
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
|
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
|
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
|
@@ -409,33 +448,22 @@ ACCESS_TOKEN=$(jq -r '.accessstring' <<< ${curlresponse})
|
|
|
|
|
|
wait_seconds 3
|
|
wait_seconds 3
|
|
|
|
|
|
-echo "Configuring netmaker server as ingress gateway"
|
|
|
|
|
|
+echo "Installing Netclient"
|
|
|
|
+setup_netclient
|
|
|
|
|
|
-for i in 1 2 3 4 5 6
|
|
|
|
-do
|
|
|
|
- echo " waiting for server node to become available"
|
|
|
|
- wait_seconds 10
|
|
|
|
- curlresponse=$(curl -s -H "Authorization: Bearer $MASTER_KEY" -H 'Content-Type: application/json' https://api.${NETMAKER_BASE_DOMAIN}/api/nodes/netmaker)
|
|
|
|
- SERVER_ID=$(jq -r '.[0].id' <<< ${curlresponse})
|
|
|
|
- echo " Server ID: $SERVER_ID"
|
|
|
|
- if [ $SERVER_ID == "null" ]; then
|
|
|
|
- SERVER_ID=""
|
|
|
|
- fi
|
|
|
|
- if [[ "$i" -ge "6" && -z "$SERVER_ID" ]]; then
|
|
|
|
- echo " Netmaker is having issues configuring itself, please investigate (docker logs netmaker)"
|
|
|
|
- echo " Exiting..."
|
|
|
|
- exit 1
|
|
|
|
- elif [ -z "$SERVER_ID" ]; then
|
|
|
|
- echo " server node not yet configured, retrying..."
|
|
|
|
- elif [[ ! -z "$SERVER_ID" ]]; then
|
|
|
|
- echo " server node is now availble, continuing"
|
|
|
|
- break
|
|
|
|
- fi
|
|
|
|
-done
|
|
|
|
|
|
+echo "Adding Netclient to Network"
|
|
|
|
+netclient join -t $ACCESS_TOKEN
|
|
|
|
+
|
|
|
|
+# TODO - Get Host ID
|
|
|
|
|
|
|
|
+echo "Setting Netclient as Default Host"
|
|
|
|
+HOST_ID=$(grep 'id:' /etc/netclient/netclient.yml | awk '{print $2}')
|
|
|
|
+echo $HOST_ID
|
|
|
|
+# TODO - API call to make host default
|
|
|
|
|
|
|
|
+echo "Setting Netclient as Ingress Gateway"
|
|
if [[ ! -z "$SERVER_ID" ]]; then
|
|
if [[ ! -z "$SERVER_ID" ]]; then
|
|
- curl -o /dev/null -s -X POST -H "Authorization: Bearer $MASTER_KEY" -H 'Content-Type: application/json' https://api.${NETMAKER_BASE_DOMAIN}/api/nodes/netmaker/$SERVER_ID/createingress
|
|
|
|
|
|
+ curl -o /dev/null -s -X POST -H "Authorization: Bearer $MASTER_KEY" -H 'Content-Type: application/json' https://api.${NETMAKER_BASE_DOMAIN}/api/nodes/netmaker/$HOST_ID/createingress
|
|
fi
|
|
fi
|
|
)}
|
|
)}
|
|
|
|
|