forked from elPeroN/CAS-Server
-
Notifications
You must be signed in to change notification settings - Fork 0
/
create-credentials.sh
executable file
·41 lines (30 loc) · 1.38 KB
/
create-credentials.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
#!/bin/bash
CREDENTIALS_LENGTH_USER=8
CREDENTIALS_LENGTH_PASSWORD=16
CREDENTIALS_FILE_NAME=${PWD}/env/credentials.env
replace_random() {
local length=$1
tr -dc 'a-zA-Z0-9' < /dev/urandom | fold -w "$length" | head -n 1
}
if [ -f "$CREDENTIALS_FILE_NAME" ]; then
echo "Error: File $CREDENTIALS_FILE_NAME already exists, you would overwrite and lose old credentials.
please remove the file manually."
else
echo "File $CREDENTIALS_FILE_NAME doesn't exist, creating..."
cat > env/credentials.env <<EOF
# Mattermost
CREDENTIALS_MATTERMOST_POSTGRES_USER=$(replace_random $CREDENTIALS_LENGTH_USER)
CREDENTIALS_MATTERMOST_POSTGRES_PASSWORD=$(replace_random $CREDENTIALS_LENGTH_PASSWORD)
# SonarQube
CREDENTIALS_SONAR_POSTGRES_USER=$(replace_random $CREDENTIALS_LENGTH_USER)
CREDENTIALS_SONAR_POSTGRES_PASSWORD=$(replace_random $CREDENTIALS_LENGTH_PASSWORD)
# Taiga
CREDENTIALS_TAIGA_SECRET_KEY=$(replace_random $CREDENTIALS_LENGTH_PASSWORD)
CREDENTIALS_TAIGA_POSTGRES_USER=taiga
CREDENTIALS_TAIGA_POSTGRES_PASSWORD=$(replace_random $CREDENTIALS_LENGTH_PASSWORD)
CREDENTIALS_TAIGA_EMAIL_HOST_USER=$(replace_random $CREDENTIALS_LENGTH_USER)
CREDENTIALS_TAIGA_EMAIL_HOST_PASSWORD=$(replace_random $CREDENTIALS_LENGTH_PASSWORD)
CREDENTIALS_TAIGA_RABBITMQ_USER=$(replace_random $CREDENTIALS_LENGTH_USER)
CREDENTIALS_TAIGA_RABBITMQ_PASS=$(replace_random $CREDENTIALS_LENGTH_PASSWORD)
EOF
fi