1
0
Fork 0
mirror of https://github.com/postmannen/ctrl.git synced 2024-12-15 17:51:15 +00:00
ctrl/scripts/nats-server/wrapper-docker-compose.sh

49 lines
1.6 KiB
Bash
Raw Normal View History

#!/bin/bash
# TO USE:
2021-12-07 15:00:49 +00:00
# ./wrapper fqdn 50222
2021-12-07 15:00:49 +00:00
FQDN=$1
if docker inspect --type=image certupdater:0.1.0 &>/dev/null; then
echo " * ok, certupdater docker image found"
else
echo " * No docker image for certupdater found."
echo " * A docker image of certupdater need to be present on the host."
echo " * Follow the instructions at https://github.com/RaaLabs/certupdater"
echo " * to build and install it as a docker image."
exit 1
fi
if docker run -it --rm -v "$PWD:/certs/:rw" -p 80:80 -p 443:443 -e DAEMON=false -e USER_FOLDER=/certs -e PROD=true -e DOMAIN="$FQDN" certupdater:0.1.0; then
2021-12-07 15:00:49 +00:00
echo " * successfully generated LetsEncrypt certificate"
else
echo " * failed to generate LetsEncrypt certificate."
exit 1
2021-12-07 15:00:49 +00:00
fi
LE_CRT=$PWD/$FQDN/$FQDN.crt
LE_KEY=$PWD/$FQDN/$FQDN.key
EXPOSED_NATS_PORT=$2
if go run ./steward/scripts/nats-server/generate-nkeys/main.go; then
echo " * succesfully generated nkeys"
else
echo " * failed to generate nkeys"
exit 1
fi
if go run ./steward/scripts/nats-server/create-docker-compose-files/main.go -imageAndVersion=nats-server:2.5.0 -natsConfPath=./nats.conf -leCertPath="$LE_CRT" -leKeyPath="$LE_KEY" -exposedNatsPort="$EXPOSED_NATS_PORT" -templateDir=./steward/scripts/nats-server/create-docker-compose-files/; then
echo " * succesfully generated docker-compose and env.env file"
else
echo " * failed to generate docker-compse and env.env file"
exit 1
fi
if ./steward/scripts/nats-server/generate-nats-conf/generate-nats-conf.sh; then
echo " * succesfully generated nats.conf"
else
echo " * failed to generate nats-conf"
exit 1
fi