-
Notifications
You must be signed in to change notification settings - Fork 0
/
configure
executable file
·170 lines (146 loc) · 5.11 KB
/
configure
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
#!/bin/bash
echo Prepare database configuration...
(umask 077 ; touch infrastructure/.env)
(umask 077 ; touch src/config.ini)
read -sp "Set root password: " rootpassvar
echo
read -sp "Repeat root password: " rootpasscmp
echo
if [ "$rootpassvar" != "$rootpasscmp" ]
then
echo root passwords not equal
exit 1
fi
read -p "Username: " uservar
if [[ -z "$uservar" ]]
then
echo no username set
exit 1
fi
read -sp "Set password for user $uservar: " userpassvar
echo
read -sp "Repeat password for user $uservar: " userpasscmp
echo
if [ "$userpassvar" != "$userpasscmp" ]
then
echo user passwords not equal
exit 1
fi
echo ...
echo MYSQL_ROOT_PASSWORD=$rootpassvar > infrastructure/.env
echo MYSQL_USER=$uservar >> infrastructure/.env
echo MYSQL_PASSWORD=$userpassvar >> infrastructure/.env
echo Docker-compose environment variables set.
echo ""
echo "... setting parameters for authentication database ..."
echo [MySQL Auth] > src/config.ini
read -p "Do you want the authentication database to run in a docker container (D) or locally (l)? " where
if [[ ( -z "$where" ) || ( "$where" = "D" ) || ( "$where" = "d" ) ]]
then
echo host = auth_db >> src/config.ini
elif [[ ( "$where" = "l" ) || ( "$where" = "l" ) ]]
then
echo host = localhost >> src/config.ini
else
echo "Please select it to run in a docker container (D) or locally (l) next time."
exit 1
fi
echo ...
echo user = $uservar >> src/config.ini
echo port = 3306 >> src/config.ini
echo passwd = $userpassvar >> src/config.ini
echo database = auth >> src/config.ini
echo >> src/config.ini
echo "... setting parameters for data database ..."
echo [MySQL Data] >> src/config.ini
read -p "Do you want the data database to run in a docker container (D) or locally (l)? " where
if [[ ( -z "$where" ) || ( "$where" = "D" ) || ( "$where" = "d" ) ]]
then
echo host = data_db >> src/config.ini
elif [[ ( "$where" = "l" ) || ( "$where" = "l" ) ]]
then
echo host = localhost >> src/config.ini
else
echo "Please select it to run in a docker container (D) or locally (l) next time."
exit 1
fi
echo user = $uservar >> src/config.ini
echo port = 3306 >> src/config.ini
echo passwd = $userpassvar >> src/config.ini
echo database = datadb >> src/config.ini
echo >> src/config.ini
echo database configuration finished.
echo ""
read -p "Enter bot token: " token
if [[ -z "$token" ]]
then
echo no token provided
exit 1
fi
read -sp "Enter password for bot: " botpassvar
echo
read -sp "Repeat password for bot: " botpasscmp
if [ "$botpassvar" != "$botpasscmp" ]
then
echo bot passwords not equal
exit 1
fi
echo ""
echo ...
echo [Bot] >> src/config.ini
echo token = $token >> src/config.ini
echo >> src/config.ini
echo [Authentication] >> src/config.ini
echo password = $botpassvar >> src/config.ini
echo >> src/config.ini
echo bot configuration finished
echo ""
touch infrastructure/init_data_categories.sql
echo "USE datadb;" > infrastructure/init_data_categories.sql
echo [GameCategories] >> src/config.ini
echo Default categories for games are:
echo lang,
echo kurz,
echo komplex,
echo simpel,
echo Kooperationsspiel,
echo Partyspiel,
echo storylastig,
echo Wuerfelspiel,
echo Kartenspiel,
echo Worker Placement,
echo Resource Management,
echo Tile Placement,
echo Deckbuilding,
echo Drafting,
echo Deduction.
echo ""
echo Having categories \'lang\' and \'kurz\' is mandatory, but if you wish, you can change the rest.
read -p "Enter a category you want to add (press Return to stay with default values): " newcategory
if [[ -z "$newcategory" ]]
then
echo "categories = lang, kurz, komplex, simpel, Kooperationsspiel, Partyspiel, storylastig, Wuerfelspiel, Kartenspiel, Worker Placement, Resource Management, Tile Placement, Deckbuilding, Drafting, Deduction" >> src/config.ini
echo "CREATE TABLE categories (\`lang\` VARCHAR(255), \`kurz\` VARCHAR(255), \`komplex\` VARCHAR(255), \`simpel\` VARCHAR(255), \`Kooperationsspiel\` VARCHAR(255), \`Partyspiel\` VARCHAR(255), \`storylastig\` VARCHAR(255), \`Wuerfelspiel\` VARCHAR(255), \`Kartenspiel\` VARCHAR(255), \`Worker Placement\` VARCHAR(255), \`Resource Management\` VARCHAR(255), \`Tile Placement\` VARCHAR(255), \`Deckbuilding\` VARCHAR(255), \`Drafting\` VARCHAR(255), \`Deduction\` VARCHAR(255));" >> infrastructure/init_data_categories.sql
else
echo -n categories = lang, kurz, $newcategory >> src/config.ini
echo -n "CREATE TABLE categories (\`lang\` VARCHAR(255), \`kurz\` VARCHAR(255), \`$newcategory\` VARCHAR(255)" >> infrastructure/init_data_categories.sql
while [[ -n "$newcategory" ]]
do
read -p "Add another category to add (press Return to stop): " newcategory
if [[ -z "$newcategory" ]]
then
echo >> src/config.ini
echo ");" >> infrastructure/init_data_categories.sql
else
echo -n , $newcategory >> src/config.ini
echo -n ", \`$newcategory\` VARCHAR(255)" >> infrastructure/init_data_categories.sql
fi
done
fi
echo >> src/config.ini
echo categories defined.
echo ""
echo >> src/config.ini
echo [GroupDetails] >> src/config.ini
read -p "Enter your group's name: " groupname
echo title = $groupname >> src/config.ini