forked from iNethi/master-builder
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild_all.sh
executable file
·207 lines (166 loc) · 5.14 KB
/
build_all.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
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
#!/bin/bash
# install all dependencies
sudo apt-get update
sudo apt-get install -y \
ca-certificates \
curl \
gnupg \
lsb-release
sudo curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg
echo \
"deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/ubuntu \
$(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
sudo apt-get update
sudo apt-get -y install docker-ce docker-ce-cli containerd.io docker-compose-plugin
sudo apt-get -y install docker-compose
# Make docker run as non root
sudo usermod -aG docker $USER
sudo chmod 666 /var/run/docker.sock
# customize with your own.
sudo mkdir -p /mnt/data
# make sure all future data in this folder can be created as non root
sudo chown $USER:$USER /mnt/data
## NOTES
# Need to add opton to capture email for fields in inethi-traefikssl
options=("jellyfin" "keycloak" "nginx(splash)" "moodle" "nextcloud" "wordpress" "unifi" "radiusdesk" "payments")
entrypoint=web
menu() {
echo "iNethi (Traefik) version 0.1.0 builder"
echo
echo "Avaliable options:"
for i in ${!options[@]}; do
printf "%3d%s) %s\n" $((i+1)) "${choices[i]:- }" "${options[i]}"
done
if [[ "$msg" ]]; then echo "$msg"; fi
}
prompt="Select which iNethi components you want (again to uncheck, ENTER when done): "
while menu && read -rp "$prompt" num && [[ "$num" ]]; do
[[ "$num" != *[![:digit:]]* ]] &&
(( num > 0 && num <= ${#options[@]} )) ||
{ msg="Invalid option: $num"; continue; }
((num--));
[[ "${choices[num]}" ]] && choices[num]="" || choices[num]="+"
done
echo
echo Set General master secure password for all services
read -p 'master password: ' MASTER_PASSWORD
# Set for Nextcloud
mkdir -p ./nextcloud/secrets
echo export MYSQL_ROOT_PASSWORD=$MASTER_PASSWORD > ./nextcloud/secrets/secret_passwords.env
echo export MYSQL_PASSWORD=$MASTER_PASSWORD >> ./nextcloud/secrets/secret_passwords.env
echo
# Select domain namec
read -p 'Doman name: ' domainName
# Select https or http
echo "Do you wish to deploy a secure site with https?"
select yn in "Yes" "No"; do
case $yn in
Yes ) entrypoint=websecure; break;;
No ) entrypoint=web; break;;
esac
done
echo
printf "You selected"; msg=" nothing"
for i in ${!options[@]}; do
[[ "${choices[i]}" ]] && {
printf " %s" "[${options[i]}]"; msg="";
}
done
echo "$msg"
if [ "$entrypoint" = websecure ]; then
echo You chose secure Domain Name: https://$domainName
echo
echo API keys are needed to setup https certificates
if test -f traefikssl/secrets/secret_keys.env; then
echo API key file exists
cat traefikssl/secrets/secret_keys.env
else
read -p 'AWS_ACCESS_KEY_ID: ' AWS_ACCESS_KEY_ID
read -p 'AWS_SECRET_ACCESS_KEY: ' AWS_SECRET_ACCESS_KEY
read -p 'AWS_HOSTED_ZONE_ID: ' AWS_HOSTED_ZONE_ID
mkdir -p ./traefikssl/secrets/
echo AWS_ACCESS_KEY_ID=$AWS_ACCESS_KEY_ID > ./traefikssl/secrets/secret_keys.env
echo AWS_SECRET_ACCESS_KEY=$AWS_SECRET_ACCESS_KEY >> ./traefikssl/secrets/secret_keys.env
echo AWS_HOSTED_ZONE_ID=$AWS_HOSTED_ZONE_ID >> ./traefikssl/secrets/secret_keys.env
fi
else
echo You chose insecure Domain Name: http://$domainName
fi
echo
printf "Starting to build dockers ... "
echo
# # Send the environmental variables to other scripts
echo export inethiDN=$domainName > ./root.conf
echo export TRAEFIK_ENTRYPOINT=$entrypoint >> ./root.conf
printf "Create docker traefik bridge: traefik-bridge ..."
echo
docker network create --attachable -d bridge inethi-bridge-traefik
printf "Pulling dnsmasq and traefik..."
echo
# Build traefik - compulsory docker
[ "$entrypoint" = websecure ] && {
printf "Building Traefik docker... "
cd ./traefikssl
./local_build.sh
cd ..
}
[ "$entrypoint" = web ] && {
printf "Building Traefik docker... "
cd ./traefik
./local_build.sh
cd ..
}
[[ "${choices[0]}" ]] && {
printf "Building jellyfin docker ... "
cd ./jellyfin
./local_build.sh
cd ..
}
[[ "${choices[1]}" ]] && {
printf "Building keycloak docker ... "
cd ./keycloak
./local_build.sh
cd ..
}
[[ "${choices[2]}" ]] && {
printf "Building nginx(splash) docker ... "
cd ./nginx-splash
./local_build.sh
cd ..
}
[[ "${choices[3]}" ]] && {
printf "Building Moodle docker ... "
cd ./moodle
./local_build.sh
cd ..
}
[[ "${choices[4]}" ]] && {
printf "Building Nextcloud docker ... "
cd ./nextcloud
./local_build.sh
cd ..
}
[[ "${choices[5]}" ]] && {
printf "Building wordpress docker ... "
cd ./wordpress
./local_build.sh
cd ..
}
[[ "${choices[6]}" ]] && {
printf "Building Unifi Controller docker ... "
cd ./unificontroller
./local_build.sh
cd ..
}
[[ "${choices[7]}" ]] && {
printf "Building Radiusdesk docker ... "
cd ./radiusdesk_2docker
./local_build.sh
cd ..
}
[[ "${choices[8]}" ]] && {
printf "Building Payment system docker ... "
cd ./payments
./local_build.sh
cd ..
}