96 lines
1.9 KiB
Bash
Executable File
96 lines
1.9 KiB
Bash
Executable File
#!/bin/bash
|
|
|
|
force=false
|
|
|
|
# Direcotires of the services in ascending order regarding their dependancies
|
|
declare -a services=(ReverseProxy Turn SpreedSignaling Nextcloud Synapse TelegramBridge SolarLog WhatsappBridge Portfolio Gitea Drone AfKU Searx TestSite)
|
|
|
|
usage() {
|
|
echo "Usage: $0 \n
|
|
-r restart \n
|
|
-p start \n
|
|
-s stop \n
|
|
-f force (for restart) \n
|
|
-h help" 1>&2; exit 1;
|
|
}
|
|
|
|
# No flags passed
|
|
if [[ $# -eq 0 ]]
|
|
then
|
|
usage
|
|
fi
|
|
|
|
# Flags passed
|
|
while getopts 'rsfhp' flag
|
|
do
|
|
case "${flag}" in
|
|
r)
|
|
action=restart
|
|
;;
|
|
p)
|
|
action=start
|
|
;;
|
|
s)
|
|
action=stop
|
|
;;
|
|
f)
|
|
force=true
|
|
;;
|
|
h | *)
|
|
usage
|
|
;;
|
|
esac
|
|
done
|
|
|
|
if [[ $action = restart ]]
|
|
then
|
|
echo "Restarting all services"
|
|
|
|
if [[ $force = true ]]
|
|
then
|
|
for (( idx=${#services[@]}-1 ; idx>=0 ; idx-- ))
|
|
do
|
|
docker-compose -f ./${services[idx]}/docker-compose.yml down
|
|
done
|
|
|
|
for e in "${services[@]}"
|
|
do
|
|
docker-compose -f ./${e}/docker-compose.yml up --build -d
|
|
done
|
|
else
|
|
for e in "${services[@]}"
|
|
do
|
|
docker-compose -f ./${e}/docker-compose.yml restart
|
|
done
|
|
fi
|
|
fi
|
|
|
|
if [[ $action = stop ]]
|
|
then
|
|
echo "Stopping all services"
|
|
|
|
if [[ $force = true ]]
|
|
then
|
|
for (( idx=${#services[@]}-1 ; idx>=0 ; idx-- ))
|
|
do
|
|
docker-compose -f ./${services[idx]}/docker-compose.yml down
|
|
done
|
|
|
|
else
|
|
for (( idx=${#services[@]}-1 ; idx>=0 ; idx-- ))
|
|
do
|
|
docker-compose -f ./${services[idx]}/docker-compose.yml stop
|
|
done
|
|
fi
|
|
fi
|
|
|
|
if [[ $action = start ]]
|
|
then
|
|
echo "Starting all services"
|
|
|
|
for (( idx=${#services[@]}-1 ; idx>=0 ; idx-- ))
|
|
do
|
|
docker-compose -f ./${services[idx]}/docker-compose.yml up -d
|
|
done
|
|
fi
|