Last active
October 14, 2022 16:31
-
-
Save abhishek9686/191eaf31c634b00bcc0e9da5dc8e8c5e to your computer and use it in GitHub Desktop.
Netmake v0.16.1 Upgrade Script
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# set -x | |
****** YOU CAN PASS YOUR OWN BASE DOMAIN AS ARGUMENT TO SCRIPT [ example: ./upgrade.sh nm.167-99-151-159.nip.io ] ******* | |
docker-compose down | |
# get required files | |
wget https://github.com/mikefarah/yq/releases/download/v4.28.1/yq_linux_amd64 -O /usr/local/bin/yq && chmod +x /usr/local/bin/yq | |
wget -O /root/mosquitto.conf https://raw.githubusercontent.com/gravitl/netmaker/release_v0.16.1/docker/mosquitto.conf | |
wget -O /root/wait.sh https://raw.githubusercontent.com/gravitl/netmaker/release_v0.16.1/docker/wait.sh | |
chmod +x /root/wait.sh | |
NETMAKER_BASE_DOMAIN=${1} | |
if [[ -z ${NETMAKER_BASE_DOMAIN} ]]; then | |
NETMAKER_BASE_DOMAIN=nm.$(curl -s ifconfig.me | tr . -).nip.io | |
fi | |
# Update docker-compose.yml | |
## Netmaker service updates | |
yq -i '.services.netmaker.image = "gravitl/netmaker:v0.16.1"' /root/docker-compose.yml | |
MQ_ADMIN_PASSWORD=$(tr -dc A-Za-z0-9 </dev/urandom | head -c 64 ; echo '') yq -i '.services.netmaker.environment.MQ_ADMIN_PASSWORD = strenv(MQ_ADMIN_PASSWORD)' /root/docker-compose.yml | |
if yq -e '(.services.netmaker.volumes.[] | select(. == "shared_certs:/etc/netmaker"))' /root/docker-compose.yml; then | |
yq -i '(.services.netmaker.volumes.[] | select(. == "shared_certs:/etc/netmaker")) |= "mosquitto_data:/etc/netmaker"' /root/docker-compose.yml | |
else | |
yq -i '.services.netmaker.volumes += "mosquitto_data:/etc/netmaker"' /root/docker-compose.yml | |
fi | |
## MQ service updates | |
yq -i '.services.mq.command = ["/mosquitto/config/wait.sh"]' /root/docker-compose.yml | |
yq -i '.services.mq.environment.NETMAKER_SERVER_HOST = "https://api.NETMAKER_BASE_DOMAIN"' /root/docker-compose.yml | |
yq -i '.services.mq.volumes += "/root/wait.sh:/mosquitto/config/wait.sh"' /root/docker-compose.yml | |
yq -i 'del( .services.mq.volumes.[] | select(. == "shared_certs:/mosquitto/certs") )' /root/docker-compose.yml | |
yq -i '.services.mq.labels = ["traefik.enable=true","traefik.tcp.routers.mqtt.rule=HostSNI(`broker.NETMAKER_BASE_DOMAIN`)","traefik.tcp.routers.mqtt.tls.certresolver=http","traefik.tcp.services.mqtt.loadbalancer.server.port=8883","traefik.tcp.routers.mqtt.entrypoints=websecure"]' /root/docker-compose.yml | |
yq -i 'del( .volumes.shared_certs )' /root/docker-compose.yml | |
sed -i "s/NETMAKER_BASE_DOMAIN/$NETMAKER_BASE_DOMAIN/g" /root/docker-compose.yml | |
## Netmaker-Ui service updates | |
yq -i '.services.netmaker-ui.image = "gravitl/netmaker-ui:v0.16.1"' /root/docker-compose.yml | |
docker-compose up -d |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
thanks for the feedback updated the script accordingly