forked from jasonacox/Powerwall-Dashboard
-
Notifications
You must be signed in to change notification settings - Fork 0
/
compose-dash.sh
executable file
·72 lines (65 loc) · 2.06 KB
/
compose-dash.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
#!/bin/bash
#
# Convenience script for docker-compose
# Enables
# - docker-compose and docker compose (v1, v2)
# - moves multiple versions of unwieldy compose invocation to one place
# - very convenient for starting and stopping containers when developing.
# Takes up to two arguments, typically "up -d", "start", and "stop"
# Always verifies docker and docker-compose, as it is run infrequently.
# by BuongiornoTexas 16 Oct 2022
# Stop on Errors
set -e
# Set Globals
COMPOSE_ENV_FILE="compose.env"
# Check for Arguments
if [ -z "$1" ]
then
echo "Powerwall-Dashboard helper script for docker-compose"
echo ""
echo "Usage:"
echo " ${0} [COMMAND] [ARG]"
echo ""
echo "Commands (see docker-compose for full list):"
echo " up -d Create and start containers"
echo " start Start services"
echo " stop Stop services"
exit 1
fi
# Docker Dependency Check
if ! docker info > /dev/null 2>&1; then
echo "ERROR: docker is not available or not running."
echo "This script requires docker, please install and try again."
exit 1
fi
# Load environment variables for compose
if [ ! -f ${COMPOSE_ENV_FILE} ]; then
echo "ERROR: Missing ${COMPOSE_ENV_FILE} file."
echo "Please run setup.sh or copy ${COMPOSE_ENV_FILE}.sample to ${COMPOSE_ENV_FILE}."
exit 1
fi
set -a
. "${COMPOSE_ENV_FILE}"
set +a
# Docker Compose Extension Check
if [ -f "powerwall.extend.yml" ]; then
echo "Including powerwall.extend.yml"
pwextend="-f powerwall.extend.yml"
else
pwextend=""
fi
echo "Running Docker Compose..."
if docker compose version > /dev/null 2>&1; then
# Build Docker (v2)
docker compose -f powerwall.yml $pwextend $@
else
if docker-compose version > /dev/null 2>&1; then
# Build Docker (v1)
docker-compose -f powerwall.yml $pwextend $@
else
echo "ERROR: docker-compose/docker compose is not available or not running."
echo "This script requires docker-compose or docker compose."
echo "Please install and try again."
exit 1
fi
fi