-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinit-weagle-local.sh
executable file
·142 lines (117 loc) · 3.36 KB
/
init-weagle-local.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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
#!/bin/bash
# init weagle
echo -e "\033[0;62m\033[0;49;35m"
set -a && source .env.common.local.private && set +a
set -a && source .env.ingress.local.private && set +a
root_dir="$(pwd)"
log () {
echo -e "\033[0;49;35m"
# warning
if [[ "$2" == "2" ]]; then
echo -e "\033[35;43m$1\033[0m"
fi
# error
if [[ "$2" == "1" ]]; then
echo -e "\033[35;41m\033[33m$1\033[0m"
fi
# success
if [[ "$2" == "0" ]]; then
echo -e "\033[35;42m$1\033[0m"
fi
# normal
if [[ "$2" == "" ]]; then
echo -e "\033[35;46m$1\033[0m"
fi
}
prompt () {
log "$1" 2
read answer
echo "$answer"
}
gosu () {
if [ $( id -u ) -ne 0 ]; then
log "dp::(auth)::this command needs sudo, please add password for %p: " 2
sudo -v
# exit $?
fi
}
take () {
log "dp::(idle)::let's wait $1 seconds for $2." 2
while true; do echo -n .; sleep 1; done | pv -s $1 -S -F '%t %p' > /dev/null
}
# docker setup
log "dp::hermes::hermes_net_weagle::(busy)::creating Docker network."
docker network create \
--driver bridge \
--subnet=129.101.0.0/24 \
--gateway=129.101.0.1 \
--attachable \
weagle
log "dp::hermes::hermes_net_weagle::(busy)::creating Docker network."
docker network create \
--driver bridge \
--subnet=129.101.101.0/24 \
--gateway=129.101.101.1 \
--attachable \
mail
# docker setup
log "dp::hermes::hermes_net_weagle::(busy)::creating Docker network."
docker network create \
--driver bridge \
--subnet=129.101.102.0/24 \
--gateway=129.101.102.1 \
--attachable \
cloud
log "dp::hermes::hermes_net_weagle::(busy)::creating Docker network."
docker network create \
--driver bridge \
--subnet=129.102.103.0/24 \
--gateway=129.102.103.1 \
--attachable \
matrix
log "dp::hermes::hermes_net_weagle::(busy)::preparing Weagle (Ingress: Traefik, Grafana, Prometheus) configuration files." 2
origin="./ingress/_docker-compose-local.yml"
destination="./ingress/docker-compose.yml"
tmpfile=$(mktemp)
cp -p $origin $tmpfile
cat $origin | envsubst > $tmpfile && mv $tmpfile $destination
origin="./ingress/_traefik-local.yml"
destination="./ingress/traefik.yml"
tmpfile=$(mktemp)
cp -p $origin $tmpfile
cat $origin | envsubst > $tmpfile && mv $tmpfile $destination
origin="./ingress/_dynamic-local.yml"
destination="./ingress/dynamic.yml"
tmpfile=$(mktemp)
cp -p $origin $tmpfile
cat $origin | envsubst > $tmpfile && mv $tmpfile $destination
origin="./ingress/_prometheus.yml"
destination="./ingress/prometheus.yml"
tmpfile=$(mktemp)
cp -p $origin $tmpfile
cat $origin | envsubst > $tmpfile && mv $tmpfile $destination
origin="./ingress/_alertmanager.yml"
destination="./ingress/alertmanager.yml"
tmpfile=$(mktemp)
cp -p $origin $tmpfile
cat $origin | envsubst > $tmpfile && mv $tmpfile $destination
# dir setup
log "dp::hermes::hermes_net_weagle::(busy)::creating folder structure."
cd ingress
mkdir data
cd data
mkdir traefik
cd traefik
# dir setup
log "dp::hermes::hermes_net_weagle::(busy):: Creating (localhost) .PEM certificates (Snakeoil)." 2
mkcert $HERMES_HOSTNAME
cd $root_dir
take 5 "dp::hermes::hermes_net_weagle::(busy):: Launching Docker Compose Swarms."
cd ingress
# docker pull ghcr.io/dreampipcom/${HERMES_REPO}:main
# docker stop ${}
# docker rm hypnos
# docker run -d --name hypnos --restart unless-stopped -p 3001:3001 ghcr.io/dreampipcom/hypnos:main
docker compose up -d
cd $root_dir
log "dp::hermes::hermes_net_weagle::(idle)::all good." 0