forked from eugene-khyst/letsencrypt-docker-compose
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcli.sh
More file actions
executable file
·104 lines (86 loc) · 2.07 KB
/
cli.sh
File metadata and controls
executable file
·104 lines (86 loc) · 2.07 KB
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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
#!/bin/bash
usage() {
cat << EOF
Usage: $(basename "$0") COMMAND
config [OPTIONS] Run the CLI tool
--no-current-user Run as root (Docker default) instead of the current user
up [OPTIONS] Build, (re)create, and start all services in the background
--dry-run Disable Certbot to run all services locally
build [OPTIONS] Build or rebuild all Docker images
--no-cache Do not use cache when building the images
EOF
exit 1
}
run_cli() {
docker-compose run --rm cli
}
run_docker_compose_up() {
docker-compose up -d
}
run_docker_compose_build() {
docker-compose --profile config build "${@}"
}
handle_config_command() {
CMD=run_cli
CURRENT_USER="$(id -u):$(id -g)"
DOCKER_GROUP="$(getent group docker | cut -d: -f3)"
export CURRENT_USER DOCKER_GROUP
shift
while [[ $# -gt 0 ]]; do
case $1 in
--no-current-user)
unset CURRENT_USER
unset DOCKER_GROUP
shift
;;
*)
echo "Unknown option $1"
usage
;;
esac
done
"${CMD}"
}
handle_up_command() {
CMD=run_docker_compose_up
shift
while [[ $# -gt 0 ]]; do
case $1 in
--dry-run)
export DRY_RUN=true
shift
;;
*)
echo "Unknown option $1"
usage
;;
esac
done
"${CMD}"
}
handle_build_command() {
CMD=run_docker_compose_build
shift
while [[ $# -gt 0 ]]; do
case $1 in
--no-cache)
shift
CMD+=(--no-cache)
;;
*)
echo "Unknown option $1"
usage
;;
esac
done
"${CMD[@]}"
}
main() {
case $1 in
config) handle_config_command ;;
up) handle_up_command ;;
build) handle_build_command ;;
*) echo "Unknown command $1"; usage ;;
esac
}
main "$@"