From d44766879f952a6e5718e5daa1b99e776a503028 Mon Sep 17 00:00:00 2001 From: Colin Tickle Date: Thu, 27 Apr 2023 09:01:03 +0100 Subject: [PATCH] Add project script for Dozzle --- project/dozzle | 74 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 74 insertions(+) create mode 100755 project/dozzle diff --git a/project/dozzle b/project/dozzle new file mode 100755 index 0000000..959abfa --- /dev/null +++ b/project/dozzle @@ -0,0 +1,74 @@ +#!/usr/bin/env bash + +# ALLOW THIS TO RUN FROM ANYWHERE UNDER 'docker-stack' +# IT COULD TECHNICALLY RUN ANYWHERE BUT COULD CAUSE CONFUSION +if [[ "$PWD" != *"docker-stack"* ]]; then + echo "This script can only run with the docker-stack folder tree." + exit 1; +fi +SCRIPT_PATH=$( cd "$(dirname "${BASH_SOURCE[0]}")/../" ; pwd -P ) +cd "$SCRIPT_PATH" + +# Project Variables +required_containers=( "nginx" "dozzle"); +vmhost_name="dozzle.loc"; + +############################################### +# BESPOKE FUNCTIONS AS THIS SCRIPT IS A BIT ODD +############################################### +START_PHASE=1; + +###################################### +# Start the required docker containers +###################################### +docker:start () { + ./bin/docker-compose up -d ${required_containers[*]} + host_entry_display +} + +############################ +# Stop all Docker containers +############################ +docker:stop () { + ./bin/docker-compose stop dozzle +} + +############################################ +# Show the status of all required containers +############################################ +docker:status () { + ./bin/docker-compose ps ${required_containers[*]} +} + +host_entry_display () { + echo -e " +#################################### +# Please add host entry +# +# Lighthouse server is available on +# http://${vmhost_name}/ +# +# MAC/LINUX: +# 127.0.0.1 ${vmhost_name} +# +# WINDOWS: +# 192.168.99.100 ${vmhost_name} +####################################\n"; +} + +#################################################### +# check we have a parameter, if not, echo the usage. +#################################################### +internal_setup_init () { + functions=($(compgen -A function | grep -v -e "^internal_\|^echo_info$\|^echo_warn$\|^echo_error$" | sort | tr "\r\n" " ")); + if [ $# -ne 1 ]; then + echo -e "USAGE: ${BASH_SOURCE[1]} \n\nSupported arguments ::"; + for func in "${functions[@]}"; do + echo "$func"; + done; + exit 1; + fi +} + +internal_setup_init "$@"; +$1;