-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathcontroller
executable file
·58 lines (47 loc) · 1.2 KB
/
controller
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
#! /bin/bash
#
# Usage:
# controller (start|stop)
#
# Starts or stops all of the containers.
cfg=config.inc
set -e
if [[ "$OSTYPE" == "darwin"* ]]
then
readonly ExecName=$(greadlink -f "$0")
else
readonly ExecName=$(readlink --canonicalize "$0")
fi
main()
{
local baseDir=$(dirname "$ExecName")
if [ "$#" -lt 1 ]
then
printf 'Requires either "start" or "stop" as its second parameter.\n' >&2
return 1
fi
local action="$1"
. "$baseDir/$cfg"
case "$action" in
start)
mkdir -p "$SFTPGO_LOG_DIR"
if ! command -v docker-compose > /dev/null; then
docker compose --file "$baseDir"/docker-compose.yml --project-name "$ENV_NAME" up -d
else
docker-compose --file "$baseDir"/docker-compose.yml --project-name "$ENV_NAME" up -d
fi
;;
stop)
if ! command -v docker-compose > /dev/null; then
docker compose --file "$baseDir"/docker-compose.yml --project-name "$ENV_NAME" down --remove-orphans
else
docker-compose --file "$baseDir"/docker-compose.yml --project-name "$ENV_NAME" down --remove-orphans
fi
;;
*)
printf 'Unknown command "%s"\n' "$action" >&2
return 1
;;
esac
}
main "$@"