Skip to content

Commit

Permalink
Add project script for Dozzle
Browse files Browse the repository at this point in the history
  • Loading branch information
cmtickle committed Apr 27, 2023
1 parent bd7e8c1 commit d447668
Showing 1 changed file with 74 additions and 0 deletions.
74 changes: 74 additions & 0 deletions project/dozzle
Original file line number Diff line number Diff line change
@@ -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]} <argument>\n\nSupported arguments ::";
for func in "${functions[@]}"; do
echo "$func";
done;
exit 1;
fi
}
internal_setup_init "$@";
$1;

0 comments on commit d447668

Please sign in to comment.