Skip to content

Commit

Permalink
Merge pull request #110 from blockapps/develop
Browse files Browse the repository at this point in the history
4.6.0 release
  • Loading branch information
nikitamendelbaum authored Sep 6, 2024
2 parents 87feab9 + 239ea3b commit 752b6b7
Show file tree
Hide file tree
Showing 8 changed files with 210 additions and 23 deletions.
7 changes: 7 additions & 0 deletions RELEASE_NOTES.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
# STRATO Getting Started release notes

## 4.6.0

STRATO versions supported: v11.3.1+

- Added the `notification-server` script
- Fixed the error with detecting the Compose version in utility server scripts

## 4.5.0

STRATO versions supported: v11.3.1+
Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
4.5.0
4.6.0
6 changes: 3 additions & 3 deletions highway
Original file line number Diff line number Diff line change
Expand Up @@ -88,16 +88,16 @@ then
exit 1
fi

if ! docker-compose -v &> /dev/null
if ! docker compose version &> /dev/null && ! docker-compose -v &> /dev/null
then
echo -e "${Red}Error: docker-compose is required: https://docs.docker.com/compose/install/"
echo -e "${Red}Error: Docker Compose is required: https://docs.docker.com/compose/install/"
exit 2
else
if ! docker compose version &> /dev/null
then
docker_compose="docker-compose -p highway -f docker-compose.highway.yml --log-level ERROR"
else
docker_compose="docker compose -p highway -f docker-compose.highway.yml"
docker_compose="docker -l error compose -p highway -f docker-compose.highway.yml"
fi
fi

Expand Down
6 changes: 3 additions & 3 deletions identity
Original file line number Diff line number Diff line change
Expand Up @@ -93,16 +93,16 @@ then
exit 1
fi

if ! docker-compose -v &> /dev/null
if ! docker compose version &> /dev/null && ! docker-compose -v &> /dev/null
then
echo -e "${Red}Error: docker-compose is required: https://docs.docker.com/compose/install/"
echo -e "${Red}Error: Docker Compose is required: https://docs.docker.com/compose/install/"
exit 2
else
if ! docker compose version &> /dev/null
then
docker_compose="docker-compose -p identity -f docker-compose.identity.yml --log-level ERROR"
else
docker_compose="docker compose -p identity -f docker-compose.identity.yml"
docker_compose="docker -l error compose -p identity -f docker-compose.identity.yml"
fi
fi

Expand Down
189 changes: 189 additions & 0 deletions notification-server
Original file line number Diff line number Diff line change
@@ -0,0 +1,189 @@
#!/usr/bin/env bash
set -e

Green='\033[0;32m'
Red='\033[0;31m'
Yellow='\033[0;33m'
BYellow='\033[1;33m'
NC='\033[0m'

function outputLogo {
echo '
╔╦╗┌─┐┬─┐┌─┐┌─┐┌┬┐┌─┐ ╔╗╔┌─┐┌┬┐┬┌─┐┬┌─┐┌─┐┌┬┐┬┌─┐┌┐┌┌─┐
║║║├┤ ├┬┘│ ├─┤ │ ├─┤ ║║║│ │ │ │├┤ ││ ├─┤ │ ││ ││││└─┐
╩ ╩└─┘┴└─└─┘┴ ┴ ┴ ┴ ┴ ╝╚╝└─┘ ┴ ┴└ ┴└─┘┴ ┴ ┴ ┴└─┘┘└┘└─┘
'
}

function help {
outputLogo
echo -e "${BYellow}Notification Server Run Script${NC}
Kickstart a Notification Server.
${Yellow}Optional flags:${NC}
The entrypoints are mutually exclusive.
--help|-h - this help.
--stop - stop Notification server containers (keeps containers and volumes.)
--start - start the existing Notification server containers after they were stopped (the opposite to --stop.)
--down - remove Notification server containers and leave all volumes intact.
--wipe - stop and remove Notification server containers and wipe out volumes.
--compose - fetch the latest stable docker-compose.notification.yml.
--pull - pull images used in docker-compose.notification.yml.
${Yellow}Environment variables:${NC}
HTTP_PORT - (default: 80) Port for HTTP traffic listener.
HTTPS_PORT - (default: 443) Port for HTTPS traffic listener; only used with ssl=true.
OAUTH_DISCOVERY_URL - (required) OAuth provider's OpenID Connect discovery URL.
ssl - (default: false) [true|false] to run the node with SSL/TLS.
sslCertFileType - (default: pem) [pem|crt] the SSL certificate type and file extension (should be accessible at ./ssl/certs/server.<sslCertFileType> at deploy time.)
"
}

function wipe {
echo -e "${Yellow}Removing notification server containers and wiping out volumes${NC}"
${docker_compose} down -vt 0 --remove-orphans
}

function down {
echo -e "${Yellow}Removing notification server containers${NC}"
${docker_compose} down --remove-orphans
}

function stop {
echo -e "${Yellow}Gently stopping notification server containers${NC}"
${docker_compose} stop
}

function start {
echo -e "${Yellow}Starting the earlier stopped notification server containers${NC}"
${docker_compose} start
}

function getCompose {
echo -e "${Yellow}Downloading the latest stable version of docker-compose.notification.yml...${NC}"
curl -fLo docker-compose.notification.yml https://github.com/blockapps/strato-getting-started/releases/download/$(curl -s -L https://github.com/blockapps/strato-getting-started/releases/latest | grep -om1 '"/blockapps/strato-getting-started/releases/tag/[^"]*' | grep -oE "[^/]+$")/docker-compose.notification.yml
echo -e "${Yellow}docker-compose.notification.yml downloaded successfully.${NC}"
}

function pullImages {
${docker_compose} pull
}


if [ ! -f $(pwd)/strato ]; then
echo -e "${Red}Should be run from within the strato-getting-started directory. Exit.${NC}"
exit 4
fi

if ! docker ps &> /dev/null
then
echo -e "${Red}Error: docker is required: https://www.docker.com/ . If you have it installed - you may need to execute as super user${NC}"
exit 1
fi

if ! docker compose version &> /dev/null && ! docker-compose -v &> /dev/null
then
echo -e "${Red}Error: Docker Compose is required: https://docs.docker.com/compose/install/"
exit 2
else
if ! docker compose version &> /dev/null
then
docker_compose="docker-compose -p notification-server -f docker-compose.notification.yml --log-level ERROR"
else
docker_compose="docker -l error compose -p notification-server -f docker-compose.notification.yml"
fi
fi

STRATOGS_REQUIRED_VERSION=$(grep strato-getting-started-min-version docker-compose.notification.yml | awk -F":" '{print $NF}')
if [ ${STRATOGS_REQUIRED_VERSION} ]; then
STRATOGS_CURRENT_VERSION=$(< VERSION)
if ! awk -v VER=${STRATOGS_CURRENT_VERSION//.} -v REQ_VER=${STRATOGS_REQUIRED_VERSION//.} 'BEGIN {exit (VER < REQ_VER)}'
then
echo -e "${Red}The STRATO version from docker-compose.notification.yml is incompatible with this strato-getting-started. Please update to v${STRATOGS_REQUIRED_VERSION}."
exit 12
fi
fi

while [ ${#} -gt 0 ]; do
case "${1}" in
--help|-h)
help
exit 0
;;
--stop)
stop
exit 0
;;
--start)
start
exit 0
;;
--down)
down
exit 0
;;
--wipe)
wipe
exit 0
;;
--compose)
getCompose
exit 0
;;
--pull)
pullImages
exit 0
;;
*)
echo -e "${Red}Unknown flag ${1} provided, please check --help. Exit.${NC}"
exit 5
;;
esac
shift 1
done

outputLogo

if [ "$ssl" = true ] ; then
http_protocol=https
main_port=${HTTPS_PORT}
else
http_protocol=http
main_port=${HTTP_PORT}
fi
export sslCertFileType=${sslCertFileType:-pem}

echo "" && echo "*** Common Config ***"
echo "HTTP_PORT: $HTTP_PORT"
echo "HTTPS_PORT: $HTTPS_PORT"
echo "ssl: $ssl"
echo "sslCertFileType: $sslCertFileType"

if [ ! -f docker-compose.notification.yml ]
then
getCompose
else
echo -e "${BYellow}Using the existing docker-compose.notification.yml (to download the most recent stable version - remove the file and restart the script)${NC}"
fi

# COMPOSE FILE PRE-PROCESSING
function cleanup {
rm docker-compose-notification-temp.yml
}
trap cleanup EXIT

if [ "$ssl" != true ]; then
sed -n '/#TAG_REMOVE_WHEN_NO_SSL/!p' docker-compose.notification.yml > docker-compose-notification-temp.yml
else
if [ "$HTTPS_PORT" != "443" ]; then
sed -n '/#TAG_REMOVE_WHEN_SSL_CUSTOM_HTTPS_PORT/!p' docker-compose.notification.yml > docker-compose-notification-temp.yml
else
cp docker-compose.notification.yml docker-compose-notification-temp.yml
fi
fi
# END OF COMPOSE FILE PRE-PROCESSING

${docker_compose} -f docker-compose-notification-temp.yml up -d --remove-orphans
until curl --silent --output /dev/null --fail --insecure --location "${http_protocol}://localhost:${main_port}/_ping" ; do sleep 0.5; done

echo -e "\n${Green}STRATO Notification Server has awoken.${NC}"
6 changes: 3 additions & 3 deletions payment-server
Original file line number Diff line number Diff line change
Expand Up @@ -91,16 +91,16 @@ then
exit 1
fi

if ! docker-compose -v &> /dev/null
if ! docker compose version &> /dev/null && ! docker-compose -v &> /dev/null
then
echo -e "${Red}Error: docker-compose is required: https://docs.docker.com/compose/install/"
echo -e "${Red}Error: Docker Compose is required: https://docs.docker.com/compose/install/"
exit 2
else
if ! docker compose version &> /dev/null
then
docker_compose="docker-compose -p payment-server -f docker-compose.payment.yml --log-level ERROR"
else
docker_compose="docker compose -p payment-server -f docker-compose.payment.yml"
docker_compose="docker -l error compose -p payment-server -f docker-compose.payment.yml"
fi
fi

Expand Down
11 changes: 1 addition & 10 deletions strato
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ fi

if ! docker compose version &> /dev/null && ! docker-compose -v &> /dev/null
then
echo -e "${Red}Error: docker-compose is required: https://docs.docker.com/compose/install/"
echo -e "${Red}Error: Docker Compose is required: https://docs.docker.com/compose/install/"
exit 2
else
if ! docker compose version &> /dev/null
Expand Down Expand Up @@ -336,15 +336,6 @@ then
export isRootNode=true
# Generate random networkID if not provided for --single mode
export networkID=${networkID:-$(($RANDOM * $RANDOM * $RANDOM))}
# TODO: Update and re-enable the in-place single node restart process
#if [[ $(docker ps -a | grep strato${CNAME_SEP}strato${CNAME_SEP}1) ]]; then
# echo -e "${BYellow}Updating the existing STRATO Single node instance - getting it's blockstanbul variables...${NC}"
# STRATO_ENV_VARS=$(docker inspect --format='{{range .Config.Env}}{{println .}}{{end}}' strato${CNAME_SEP}strato${CNAME_SEP}1)
# export blockstanbulAdmins=$(echo "${STRATO_ENV_VARS}" | grep blockstanbulAdmins | awk -F"ulAdmins=" '{print $2}')
# export validators=$(echo "${STRATO_ENV_VARS}" | grep validators | awk -F"alidators=" '{print $2}')
# export generateKey=false
#fi
else
if [[ ${generateKey} = false ]]; then
Expand Down
6 changes: 3 additions & 3 deletions vault
Original file line number Diff line number Diff line change
Expand Up @@ -123,17 +123,17 @@ then
exit 1
fi

if ! docker-compose -v &> /dev/null
if ! docker compose version &> /dev/null && ! docker-compose -v &> /dev/null
then
echo -e "${Red}Error: docker-compose is required: https://docs.docker.com/compose/install/"
echo -e "${Red}Error: Docker Compose is required: https://docs.docker.com/compose/install/"
exit 2
else
if ! docker compose version &> /dev/null
then
docker_compose="docker-compose -p vault -f docker-compose.vault.yml --log-level ERROR"
CNAME_SEP="_"
else
docker_compose="docker compose -p vault -f docker-compose.vault.yml"
docker_compose="docker -l error compose -p vault -f docker-compose.vault.yml"
CNAME_SEP="-"
fi
fi
Expand Down

0 comments on commit 752b6b7

Please sign in to comment.