-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrit.sh
executable file
·85 lines (68 loc) · 2.43 KB
/
rit.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
73
74
75
76
77
78
79
80
81
82
83
84
#!/usr/bin/env bash
# source library lib-dh.sh
if [[ -z $DH_ENV_HOME ]]; then
DH_ENV_HOME=".."
echo "(DH_ENV_HOME not set, using parent folder as default)"
fi
. $DH_ENV_HOME/lib-dh.sh
# Set logging level based on -v (--verbose) or -vv param
ARGS="$@ "
if [[ ${ARGS} = *"-vv "* ]]; then
export LOGTRESHOLD=$DBG
ARGS="${ARGS/-vv /}"
elif [[ ${ARGS} = *"--verbose "* ]] || [[ ${ARGS} = *"-v "* ]]; then
export LOGTRESHOLD=$INF
ARGS="${ARGS/--verbose /}"
ARGS="${ARGS/-v /}"
fi
# Set the prefix for the project
COMPOSE_PROJECT_NAME="common"
export COMPOSE_PROJECT_NAME
set -e
# specify externals for this project
externals="externals/nagios-docker https://github.com/MaastrichtUniversity/nagios-docker.git
externals/elastalert-docker https://github.com/MaastrichtUniversity/elastalert-docker.git
externals/dh-fail2ban https://github.com/MaastrichtUniversity/dh-fail2ban.git"
# do the required action in case of externals or exec
if [[ $1 == "externals" ]]; then
action=${ARGS/$1/}
run_repo_action ${action} "${externals}"
exit 0
fi
if [[ $1 == "exec" ]]; then
run_docker_exec ${COMPOSE_PROJECT_NAME} $2
exit 0
fi
if [[ $1 == "login" ]]; then
source './.env'
docker login $ENV_REGISTRY_HOST
exit 0
fi
# set RIT_ENV if not set already
env_selector
# Create networks
if ! docker network inspect dev_dh_public > /dev/null 2>&1; then
docker network create dev_dh_public --subnet "172.22.1.0/24" --label "com.docker.compose.project"="dev" --label "com.docker.compose.network"="dh_public"
fi
if ! docker network inspect dev_default > /dev/null 2>&1; then
docker network create dev_default --subnet "172.21.1.0/24" --label "com.docker.compose.project"="dev" --label "com.docker.compose.network"="default"
fi
# Create volumes
if [ ! $(docker volume ls --filter name=dev_static_content --format="true") ] ;
then
echo "Creating volume dev_static_content"
docker volume create --name=dev_static_content
fi
if [ ! $(docker volume ls --filter name=dev_webdav_logs --format="true") ] ;
then
echo "Creating volume dev_webdav_logs"
docker volume create --name=dev_webdav_logs
fi
if [ ! $(docker volume ls --filter name=dev_upload_logs --format="true") ] ;
then
echo "Creating volume dev_upload_logs"
docker volume create --name=dev_upload_logs
fi
# Assuming docker-compose is available in the PATH
log $DBG "$0 [docker-compose \"$ARGS\"]"
docker compose $ARGS