forked from ericwastaken/network-multitool
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathx-build.sh
executable file
·37 lines (30 loc) · 944 Bytes
/
x-build.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
#!/bin/bash
# Hold instance state when the script starts
INSTANCE_UP=false
# detect if docker is installed
if ! [ -x "$(command -v docker)" ]; then
echo "Docker is not installed. Please install docker and try again."
exit 1
fi
# detect if docker-compose is installed
if ! [ -x "$(command -v docker-compose)" ]; then
echo "Docker Compose is not installed. Please install docker-compose and try again."
exit 1
fi
# detect if the network-multitool container is running
if [ "$(docker ps -q -f name=network-multitool)" ]; then
# stop the compose
INSTANCE_UP=true
fi
# if INSTANCE_UP is true, then stop the container
if [ "$INSTANCE_UP" = true ]; then
# stop the compose
docker compose down
fi
# Build the container (rebuilds if already built)
docker compose build
# if INSTANCE_UP is true, then start the container back up
if [ "$INSTANCE_UP" = true ]; then
# start the compose
docker compose up -d
fi