-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
configure.sh
428 lines (396 loc) · 20.4 KB
/
configure.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
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
#!/bin/bash
function usage () {
cat << EOF
usage: $0 -n domain.com -e x@gmail.com -k cf_api_key -t discord_token -s staging_discord_token -h 1.1.1.1 -d -g -a
OPTIONS:
-h Show this message
-d Use defaults for any remaining prompts possible, in conjunction with the -nektspza flags, can be used to not ever prompt users. Sets SSH_USER, SSH_PORT, STAGING, USE_GITHUB_SECRETS, AUTO_GENERATE_CREDS to 'root, 22, yes, yes, and yes' respectively.
-n Specifies the domain registered in Cloudflare.com
-e Specifies the email address used in the Cloudflare.com account
-k Specifies the Cloudflare.com API Key. Needs at least DNS Read/Write. Create it here https://developers.cloudflare.com/api/tokens/create/
-t Specifies the Discord token. Follow the instructions here https://www.writebots.com/discord-bot-token/#generating_your_token_step-by-step
-s Specifies the Staging Discord token. Can be the same as the normal discord token if you do not want a staging discord server.
-p Specifies the host or IP of the docker compose host server
-z Specifies the Zone ID of the Cloudflare domain specified with -d https://community.cloudflare.com/t/where-to-find-zone-id/132913
-g Creates the GH secrets for you (requires gh client installation)
-a Dont use password authentication at all, instead generate the SSH key FIRST that will be put on the remote SSH server
EOF
}
function check_if_docker () {
if $(docker --help > /dev/null 2>&1); then
echo "Docker installed, proceeding"
else
echo "Docker Client is not installed, please install it"
exit 0
fi
}
function gen_alphanumeric () {
if [ "$1" == "" ]; then
length=$(( ( RANDOM % 8 ) + 12 ))
else
length="$1"
fi
echo $(tr -dc 'A-Za-z0-9_' </dev/urandom | head -c $length ; echo '')
}
function get_input () {
while getopts "agdhn:e:k:t:s:p:z:" opt; do
case ${opt} in
d )
DEFAULTS=true
STAGING="yes"
USE_GITHUB_SECRETS=true
SSH_USER="root"
SSH_PORT="22"
AUTO="yes"
;;
n )
DOMAIN=$OPTARG
;;
e )
CF_EMAIL=$OPTARG
;;
k )
CF_API_KEY=$OPTARG
;;
t )
DISCORD_TOKEN=$OPTARG
;;
s )
STAGING_DISCORD_TOKEN=$OPTARG
;;
p )
HOST_OR_IP=$OPTARG
;;
z )
CF_ZONE_ID=$OPTARG
;;
g )
USE_GITHUB_SECRETS=true
;;
a )
AUTH_KEY=true
;;
h )
usage
exit 1
;;
* )
echo "Invalid Option: -$OPTARG" 1>&2
echo "Usage: -n [Domain.com] -e [Cloudflare Email] -k [Cloudflare API Key]\
-t [Discord Token] -s [Staging Discord Token] -h 1.1.1.1 -d -g -a"
echo " e.g. -n domain.com -e x@gmail.com -k cf_api_key -t discord_token -s staging_discord_token -h 1.1.1.1 -d -g -a"
exit 1
;;
esac
done
if $AUTH_KEY; then
gen_ssh_keys
cat ~/.ssh/docker_compose_host.pub
echo
read -s -p "Add the above public key to your server's root authorized_keys file and then press enter"
echo
fi
if ! $DEFAULTS; then
echo "You will now be asked for information to help us configure your system for docker compose. Press enter to use the default value in []."
read -p 'Do you want a staging env - recommended [y]: ' STAGING
read -p 'Do you want this script to auto configure your GH repo secrets? - recommended [y]: ' GITHUB_SECRETS
GITHUB_SECRETS=${GITHUB_SECRETS:-y}
USE_GITHUB_SECRETS_TRIM=$(echo "${GITHUB_SECRETS:0:1}" | tr '[:upper:]' '[:lower:]')
if [ "$USE_GITHUB_SECRETS_TRIM" == "y" ]; then
USE_GITHUB_SECRETS=true
else
USE_GITHUB_SECRETS=false
fi
fi
if [ -z "$DOMAIN" ]; then
read -p 'Registered domain in Cloudflare: ' DOMAIN
fi
if [ -z "$CF_EMAIL" ]; then
read -p 'Cloudflare Email Address: ' CF_EMAIL
fi
if [ -z "$CF_API_KEY" ]; then
read -p 'Cloudflare API Key (needs DNS access) (https://developers.cloudflare.com/api/tokens/create/): ' CF_API_KEY
fi
if [ -z "$CF_ZONE_ID" ]; then
read -p 'Cloudflare DNS Zone ID (https://community.cloudflare.com/t/where-to-find-zone-id/132913) : ' CF_ZONE_ID
fi
if [ -z "$DISCORD_TOKEN" ]; then
read -p 'Discord Token (https://www.writebots.com/discord-bot-token/#generating_your_token_step-by-step): ' DISCORD_TOKEN
fi
STAGING="${STAGING:-y}"
AUTO_CHECK=$(echo "${STAGING:0:1}" | tr '[:upper:]' '[:lower:]')
if [ "$AUTO_CHECK" == "y" ]; then
STAGING=true
else
STAGING=false
fi
if $STAGING; then
if [ -z "$STAGING_DISCORD_TOKEN" ]; then
read -p 'Staging Discord Token (enter same token as prod if you do not have a staging Discord server): ' STAGING_DISCORD_TOKEN
fi
fi
if [ -z "$HOST_OR_IP" ]; then
read -p 'SSH Host / IP: ' HOST_OR_IP
fi
if ! $DEFAULTS; then
read -p 'SSH Username [root]: ' SSH_USER
SSH_USER=${SSH_USER:-root}
read -p 'SSH Port [22]: ' SSH_PORT
SSH_PORT=${SSH_PORT:-22}
read -p 'Would you like me to generate all remaining parameters (datatabase name, DB & Grafana username, DB & Grafana pass, and HTPASSWD values)? [y]: ' AUTO
fi
AUTO=${AUTO:-y}
AUTO_CHECK=$(echo "${AUTO:0:1}" | tr '[:upper:]' '[:lower:]')
if [ "$AUTO_CHECK" == "y" ]; then
DB_NAME=$(gen_alphanumeric 4)
DB_NAME="dbn_$DB_NAME"
DB_USER=$(gen_alphanumeric 7)
DB_USER="dbu_$DB_USER"
DB_PASS=$(gen_alphanumeric)
DB_ROOT_PASS=$(gen_alphanumeric)
GRAFANA_USER=$(gen_alphanumeric 4)
GRAFANA_USER="graf_$GRAFANA_USER"
GRAFANA_PASS=$(gen_alphanumeric)
HT_USER=$(gen_alphanumeric 4)
HT_USER="ht_$HT_USER"
HT_PASS=$(gen_alphanumeric)
EXPORTER_PASS=$(gen_alphanumeric)
if $STAGING; then
STAGING_PREFIX=$(gen_alphanumeric 4)
STAGING_PREFIX="${STAGING_PREFIX}_"
DB_STAGING_NAME="${STAGING_PREFIX}${DB_NAME}"
DB_STAGING_USER="${STAGING_PREFIX}${DB_USER}"
DB_STAGING_PASS="${STAGING_PREFIX}${DB_PASS}"
DB_STAGING_ROOT_PASS="${STAGING_PREFIX}${DB_ROOT_PASS}"
DB_STAGING_PORT=3307
fi
else
read -p 'DB Name: ' DB_NAME
read -p 'DB User: ' DB_USER
read -p 'Prod DB Password: ' DB_PASS
read -p 'Prod DB Root Password: ' DB_ROOT_PASS
read -p 'Grafana User: ' GRAFANA_USER
read -p 'Grafana Password: ' GRAFANA_PASS
read -p 'HTTP User: ' HT_USER
read -p 'HTTP Password: ' HT_PASS
read -p 'DB Exporter Pass: ' EXPORTER_PASS
if $STAGING; then
read -p 'Staging environment prefix (the string that gets prepended to staging vars): ' STAGING_PREFIX
read -p 'Staging DB Port: ' DB_STAGING_PORT
fi
fi
DATA_SOURCE_NAME="exporter:${EXPORTER_PASS}@(mariadb:3306)/${DB_NAME}"
DB_CONNECTION_STRING="mysql://exporter:${EXPORTER_PASS}@mariadb:3306/${DB_NAME}"
ENC_HTPASS=$(openssl passwd -apr1 $HT_PASS)
}
function gen_ssh_keys() {
rm -f ~/.ssh/docker_compose_host
mv ~/.ssh/config ~/.ssh/config.bak 2>/dev/null
ssh-keygen -t rsa -b 4096 -C "docker_compose_client_script" -N "" -f ~/.ssh/docker_compose_host
SSH_KEY=$(cat ~/.ssh/docker_compose_host)
PUB_KEY=$(cat ~/.ssh/docker_compose_host.pub)
}
function ssh_key_and_config () {
mv ~/.ssh/config ~/.ssh/config.bak 2>/dev/null
mv ~/.ssh/known_hosts ~/.ssh/known_hosts.bak 2>/dev/null
KNOWN_HOSTS=$(ssh-keyscan -H $HOST_OR_IP 2>&1)
echo "$KNOWN_HOSTS" >> ~/.ssh/known_hosts
if ! $AUTH_KEY; then
gen_ssh_keys
ssh $HOST_OR_IP -l $SSH_USER -p $SSH_PORT "echo $PUB_KEY >> ~/.ssh/authorized_keys"
if [ $? -ne 0 ]; then
echo "Initial SSH attempt unsuccessful. Please read the Pre-reqs section in the README.md file."
echo "Make sure PasswordAuth is set to yes on the remote server SSH config and you restarted the sshd service"
exit 1
fi
fi
echo "Setting SSH to use the generated keys in the future"
echo "Host docker-compose
HostName $HOST_OR_IP
User $SSH_USER
IdentityFile ~/.ssh/docker_compose_host
Host $HOST_OR_IP
User $SSH_USER
IdentityFile ~/.ssh/docker_compose_host" > ~/.ssh/config
ssh $HOST_OR_IP -l $SSH_USER -p $SSH_PORT "echo '127.0.0.1 host.docker.internal' >> /etc/hosts"
}
function install_config_packages () {
echo "Installing Docker engine"
ssh $HOST_OR_IP -l $SSH_USER -p $SSH_PORT "timedatectl set-timezone America/New_York"
ssh $HOST_OR_IP -l $SSH_USER -p $SSH_PORT "yum install -y yum-utils epel-release"
ssh $HOST_OR_IP -l $SSH_USER -p $SSH_PORT "yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo"
ssh $HOST_OR_IP -l $SSH_USER -p $SSH_PORT "yum install docker-ce docker-ce-cli containerd.io wget fail2ban -y"
echo "Downloading Node Exporter"
ssh $HOST_OR_IP -l $SSH_USER -p $SSH_PORT "wget https://github.com/prometheus/node_exporter/releases/download/v1.3.1/node_exporter-1.3.1.linux-amd64.tar.gz"
echo "Extracting Node Exporter"
ssh $HOST_OR_IP -l $SSH_USER -p $SSH_PORT "tar -xzf node_exporter*"
echo "Adding user for node_exporter"
ssh $HOST_OR_IP -l $SSH_USER -p $SSH_PORT "useradd -rs /bin/false node_exporter"
echo "Moving node exporter to system install location"
ssh $HOST_OR_IP -l $SSH_USER -p $SSH_PORT "mv -f node*/node_exporter /usr/local/bin"
echo "Creating service for node exporter"
ssh $HOST_OR_IP -l $SSH_USER -p $SSH_PORT 'echo "[Unit]
Description=Node Exporter
After=network.target
[Service]
User=node_exporter
Group=node_exporter
Type=simple
ExecStart=/usr/local/bin/node_exporter
[Install]
WantedBy=multi-user.target" > /etc/systemd/system/node_exporter.service'
echo "Reloading, starting, checking status and enabling node exporter on startup"
ssh $HOST_OR_IP -l $SSH_USER -p $SSH_PORT "systemctl daemon-reload"
ssh $HOST_OR_IP -l $SSH_USER -p $SSH_PORT "systemctl start node_exporter && systemctl status node_exporter && systemctl enable node_exporter"
ssh $HOST_OR_IP -l $SSH_USER -p $SSH_PORT "systemctl start docker && systemctl status docker && systemctl enable docker"
ssh $HOST_OR_IP -l $SSH_USER -p $SSH_PORT "systemctl start fail2ban && systemctl status fail2ban && systemctl enable fail2ban"
ssh $HOST_OR_IP -l $SSH_USER -p $SSH_PORT "docker plugin install grafana/loki-docker-driver:latest --alias loki --grant-all-permissions" > /dev/null 2>&1
ssh $HOST_OR_IP -l $SSH_USER -p $SSH_PORT 'sed -i "s|#MaxSessions 10|MaxSessions 30|g" /etc/ssh/sshd_config' > /dev/null 2>&1
ssh $HOST_OR_IP -l $SSH_USER -p $SSH_PORT "systemctl restart sshd" > /dev/null 2>&1
}
function configure_local () {
cd custom/
rm -f bot_staging.env bot.env db_staging.env db.env mon.env traefik.env ../traefik/.htpasswd ../query_exporter/query_exporter_config.yaml ../mariadb/initscripts/user.sql ../mariadb/initscripts/table.sql
for file in *.example; do
cp -- "$file" "${file%%.example}"
done
docker context rm docker_compose_tut -f 2>/dev/null
docker context create docker_compose_tut --docker "host=ssh://$SSH_USER@$HOST_OR_IP:$SSH_PORT"
docker context use docker_compose_tut
find . \( -type d -name .git -prune \) -o -type f ! -name "*.example" -print0 | xargs -0 sed -i "s|REPLACE_ME_DISCORD_TOKEN|$DISCORD_TOKEN|g"
find . \( -type d -name .git -prune \) -o -type f ! -name "*.example" -print0 | xargs -0 sed -i "s|REPLACE_ME_DB_NAME|$DB_NAME|g"
find . \( -type d -name .git -prune \) -o -type f ! -name "*.example" -print0 | xargs -0 sed -i "s|REPLACE_ME_DB_USER_PASS|$DB_PASS|g"
find . \( -type d -name .git -prune \) -o -type f ! -name "*.example" -print0 | xargs -0 sed -i "s|REPLACE_ME_DB_USER|$DB_USER|g"
find . \( -type d -name .git -prune \) -o -type f ! -name "*.example" -print0 | xargs -0 sed -i "s|REPLACE_ME_DB_ROOT_PASS|$DB_ROOT_PASS|g"
find ../. \( -type d -name .git -prune \) -o -type f -name "README.md" -o -name "docker*.yml" -print0 | xargs -0 sed -i "s|REPLACE_ME_DOMAIN|$DOMAIN|g"
find . \( -type d -name .git -prune \) -o -type f ! -name "*.example" -print0 | xargs -0 sed -i "s|REPLACE_ME_DOMAIN|$DOMAIN|g"
find . \( -type d -name .git -prune \) -o -type f ! -name "*.example" -print0 | xargs -0 sed -i "s|REPLACE_ME_CF_EMAIL|$CF_EMAIL|g"
find . \( -type d -name .git -prune \) -o -type f ! -name "*.example" -print0 | xargs -0 sed -i "s|REPLACE_ME_CF_DNS_API_TOKEN|$CF_API_KEY|g"
find . \( -type d -name .git -prune \) -o -type f ! -name "*.example" -print0 | xargs -0 sed -i "s|REPLACE_ME_ZONE_ID|$CF_ZONE_ID|g"
find . \( -type d -name .git -prune \) -o -type f ! -name "*.example" -print0 | xargs -0 sed -i "s|REPLACE_ME_WEB_AUTH_USER|$HT_USER|g"
find . \( -type d -name .git -prune \) -o -type f ! -name "*.example" -print0 | xargs -0 sed -i "s|REPLACE_ME_WEB_AUTH_BCRYPT_PASSWORD|$ENC_HTPASS|g"
find . \( -type d -name .git -prune \) -o -type f ! -name "*.example" -print0 | xargs -0 sed -i "s|REPLACE_ME_GRAFANA_USER|$GRAFANA_USER|g"
find . \( -type d -name .git -prune \) -o -type f ! -name "*.example" -print0 | xargs -0 sed -i "s|REPLACE_ME_GRAFANA_PASS|$GRAFANA_PASS|g"
find . \( -type d -name .git -prune \) -o -type f ! -name "*.example" -print0 | xargs -0 sed -i "s|REPLACE_ME_DATASOURCE_NAME|$DATA_SOURCE_NAME|g"
find . \( -type d -name .git -prune \) -o -type f ! -name "*.example" -print0 | xargs -0 sed -i "s|REPLACE_ME_DBC_STRING|$DB_CONNECTION_STRING|g"
find . \( -type d -name .git -prune \) -o -type f ! -name "*.example" -print0 | xargs -0 sed -i "s|REPLACE_ME_EXPORTER_PASS|$EXPORTER_PASS|g"
if $STAGING; then
find . \( -type d -name .git -prune \) -o -type f ! -name "*.example" -print0 | xargs -0 sed -i "s|REPLACE_ME_DISCORD_STAGING_TOKEN|$STAGING_DISCORD_TOKEN|g"
find . \( -type d -name .git -prune \) -o -type f ! -name "*.example" -print0 | xargs -0 sed -i "s|REPLACE_ME_DB_STAGING_NAME|$DB_STAGING_NAME|g"
find . \( -type d -name .git -prune \) -o -type f ! -name "*.example" -print0 | xargs -0 sed -i "s|REPLACE_ME_DB_STAGING_USER_PASS|$DB_STAGING_PASS|g"
find . \( -type d -name .git -prune \) -o -type f ! -name "*.example" -print0 | xargs -0 sed -i "s|REPLACE_ME_DB_STAGING_USER|$DB_STAGING_USER|g"
find . \( -type d -name .git -prune \) -o -type f ! -name "*.example" -print0 | xargs -0 sed -i "s|REPLACE_ME_DB_STAGING_ROOT_PASS|$DB_STAGING_ROOT_PASS|g"
find . \( -type d -name .git -prune \) -o -type f ! -name "*.example" -print0 | xargs -0 sed -i "s|REPLACE_ME_DB_STAGING_PORT|$DB_STAGING_PORT|g"
else
rm -f bot_staging.env
rm -f db_staging.env
rm -f ../docker-compose-staging.yml
sed -i '/# START_STAGING_HERE/,$d' ../.github/workflows/prod_and_staging.yml
fi
mv -f *.sql ../mariadb/initscripts/
mv -f traefik.htpasswd ../traefik/traefik.htpasswd
mv -f query_exporter_config.yaml ../query_exporter/
cd ../
}
function print_creds () {
configure_gh_secrets=$1
echo "Configured $HOST_OR_IP to be docker-compose ready. Please save these credentials"
echo -e "\n-- DB --"
echo "DB Root Pass is $DB_ROOT_PASS"
echo "DB Name is $DB_NAME"
echo "DB User is $DB_USER"
echo "DB Pass is $DB_PASS"
echo -e "\n-- Web Auth --"
echo "Htpasswd (Web auth) user is $HT_USER"
echo "Htpasswd (Web auth) password is $HT_PASS"
echo -e "\n-- Grafana --"
echo "Grafana User is $GRAFANA_USER"
echo "Grafana Pass is $GRAFANA_PASS"
if $STAGING; then
echo -e "\n-- Staging Environment --"
echo "The prefix that is used for staging env is $STAGING_PREFIX (for example db user in staging env would be ${STAGING_PREFIX}${DB_NAME})"
echo "Staging DB Root Pass is $DB_STAGING_ROOT_PASS"
echo "Staging DB Name is $DB_STAGING_NAME"
echo "Staging DB User is $DB_STAGING_USER"
echo "Staging DB Pass is $DB_STAGING_PASS"
echo "Staging DB Port is $DB_STAGING_PORT"
fi
if $configure_gh_secrets; then
> gh.env
KNOWN_HOSTS=$(echo -n "$KNOWN_HOSTS" | sed -z 's/\n/\\n/g')
SSH_KEY=$(echo -n "$SSH_KEY" | sed -z 's/\n/\\n/g')
echo "KNOWN_HOSTS=\"$KNOWN_HOSTS\"" >> gh.env
echo "SSH_KEY=\"$SSH_KEY\"" >> gh.env
echo "SSH_HOST=$HOST_OR_IP" >> gh.env
echo "SSH_USER=$SSH_USER" >> gh.env
echo "SSH_PORT=$SSH_PORT" >> gh.env
echo "CF_DOMAIN=$DOMAIN" >> gh.env
echo "CF_ZONE_ID=$CF_ZONE_ID" >> gh.env
echo "CF_API_KEY=$CF_API_KEY" >> gh.env
echo "CF_EMAIL=$CF_EMAIL" >> gh.env
echo "DB_NAME=$DB_NAME" >> gh.env
echo "DB_PASS=$DB_PASS" >> gh.env
echo "DB_USER=$DB_USER" >> gh.env
echo "DB_DATASOURCE=$DATA_SOURCE_NAME" >> gh.env
echo "DBC_STRING=$DB_CONNECTION_STRING" >> gh.env
echo "EXPORTER_PASS=$EXPORTER_PASS" >> gh.env
echo "DISCORD_TOKEN=$DISCORD_TOKEN" >> gh.env
echo "GF_ADMIN_USER=$GRAFANA_USER" >> gh.env
echo "GF_ADMIN_PASS=$GRAFANA_PASS" >> gh.env
echo "T_HTUSER=$HT_USER" >> gh.env
echo "T_HTPASSWD=$ENC_HTPASS" >> gh.env
if $STAGING; then
echo "STAGING_DISCORD_TOKEN=$STAGING_DISCORD_TOKEN" >> gh.env
echo "DB_STAGING_NAME=$DB_STAGING_NAME" >> gh.env
echo "DB_STAGING_USER_PASS=$DB_STAGING_PASS" >> gh.env
echo "DB_STAGING_USER=$DB_STAGING_USER" >> gh.env
echo "DB_STAGING_PORT=$DB_STAGING_PORT" >> gh.env
fi
gh auth login
gh secret set -f gh.env
rm -f gh.env
else
echo -e "\n-- ACTION REQUIRED --"
echo "If you want a fully functional automated GH Workflow (CICD), add the following secrets to the repo"
echo -e "Secret Name: KNOWN_HOSTS\nSecret Value: \n$KNOWN_HOSTS"
echo -e "Secret Name: SSH_KEY\nSecret Value: \n$SSH_KEY"
echo -e "Secret Name: SSH_HOST\nSecret Value: $HOST_OR_IP"
echo -e "Secret Name: SSH_USER\nSecret Value: $SSH_USER"
echo -e "Secret Name: SSH_PORT\nSecret Value: $SSH_PORT"
echo -e "Secret Name: CF_DOMAIN\nSecret Value: $DOMAIN"
echo -e "Secret Name: CF_ZONE_ID\nSecret Value: $CF_ZONE_ID"
echo -e "Secret Name: CF_API_KEY\nSecret Value: $CF_API_KEY"
echo -e "Secret Name: CF_EMAIL\nSecret Value: $CF_EMAIL"
echo -e "Secret Name: DB_NAME\nSecret Value: $DB_NAME"
echo -e "Secret Name: DB_PASS\nSecret Value: $DB_PASS"
echo -e "Secret Name: DB_USER\nSecret Value: $DB_USER"
echo -e "Secret Name: DB_DATASOURCE\nSecret Value: $DATA_SOURCE_NAME"
echo -e "Secret Name: DBC_STRING\nSecret Value: $DB_CONNECTION_STRING"
echo -e "Secret Name: EXPORTER_PASS\nSecret Value: $EXPORTER_PASS"
echo -e "Secret Name: DISCORD_TOKEN\nSecret Value: $DISCORD_TOKEN"
echo -e "Secret Name: GF_ADMIN_USER\nSecret Value: $GRAFANA_USER"
echo -e "Secret Name: GF_ADMIN_PASS\nSecret Value: $GRAFANA_PASS"
echo -e "Secret Name: T_HTUSER\nSecret Value: $HT_USER"
echo -e "Secret Name: T_HTPASSWD\nSecret Value: $ENC_HTPASS"
if $STAGING; then
echo -e "Secret Name: STAGING_DISCORD_TOKEN\nSecret Value: $STAGING_DISCORD_TOKEN"
echo -e "Secret Name: DB_STAGING_NAME\nSecret Value: $DB_STAGING_NAME"
echo -e "Secret Name: DB_STAGING_USER_PASS\nSecret Value: $DB_STAGING_PASS"
echo -e "Secret Name: DB_STAGING_USER\nSecret Value: $DB_STAGING_USER"
echo -e "Secret Name: DB_STAGING_PORT\nSecret Value: $DB_STAGING_PORT"
fi
fi
}
AUTH_KEY=false
DEFAULTS=false
USE_GITHUB_SECRETS=false
# Getting user input
get_input "$@"
echo "Configuring SSH hosts, keys, and fingerprints. Then will prompt you for the root password if you did not use -a flag"
ssh_key_and_config
echo "Running server side scripts"
install_config_packages
echo "Configuring local compose and env files"
configure_local
echo "Outputting credentials"
print_creds $USE_GITHUB_SECRETS