-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathconfigure
More file actions
107 lines (86 loc) · 2.62 KB
/
configure
File metadata and controls
107 lines (86 loc) · 2.62 KB
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
#!/bin/bash
# Functions
setcolor(){
printf $1
}
resetcolors(){
printf "\e[39m"
}
checkroot(){
if [ $(id -u) -ne 0 ]; then
setcolor "\e[31m"
echo "Please run as root user!"
resetcolors
exit
fi
}
#Welcome script
setcolor "\e[35m"
echo "Welcome to configuration!!"
resetcolors
checkroot
# Main vars
debug="none"
resave="none"
saveUnitialized="none"
fileconfig="assets/data/config.json"
# Reset the last config
rm -rf $fileconfig
# Save the parameters in vars
while [ $debug != "true" ] && [ $debug != "false" ]; do
read -p "Debug mode (true/false): " debug
done
read -p "Server port: " port
read -p "Api key: " apikey
read -p "Logo URL: " logo
read -p "Website name: " webname
read -p "Website description: " description
read -p "Website tags separated by comas: " tags
read -p "Contact email: " email
read -p "Website URL: " weburi
read -p "Session secret key: " secret
while [ $resave != "true" ] && [ $resave != "false" ]; do
read -p "Session resave (true/false): " resave
done
while [ $saveUnitialized != "true" ] && [ $saveUnitialized != "false" ]; do
read -p "Session save unitiliazed (true/false): " saveUnitialized
done
read -p "Session Cookie max age in milis: " cookieAge
read -p "MySQL host: " host
read -p "MySQL database: " database
read -p "MySQL user: " user
read -p "MySQL password: " password
# Create the file config
touch $fileconfig
echo "{" >> $fileconfig
echo " \"debug\": $debug," >> $fileconfig
echo " \"port\": $port," >> $fileconfig
echo " \"apiKey\": \"$apikey\"," >> $fileconfig
echo " \"logo\": \"$logo\"," >> $fileconfig
echo " \"webName\": \"$webname\"," >> $fileconfig
echo " \"description\": \"$description\"," >> $fileconfig
echo " \"tagsString\": \"$tags\"," >> $fileconfig
echo " \"email\": \"$email\"," >> $fileconfig
echo " \"webURI\": \"$weburi\"," >> $fileconfig
echo " \"session\": {" >> $fileconfig
echo " \"secret\": \"$secret\"," >> $fileconfig
echo " \"resave\": $resave," >> $fileconfig
echo " \"saveUninitialized\": $saveUnitialized," >> $fileconfig
echo " \"cookie\": {" >> $fileconfig
echo " \"maxAge\": $cookieAge" >> $fileconfig
echo " }" >> $fileconfig
echo " }," >> $fileconfig
echo " \"mysql\": {" >> $fileconfig
echo " \"supportBigNumbers\": true," >> $fileconfig
echo " \"bigNumberStrings\": true," >> $fileconfig
echo " \"host\": \"$host\"," >> $fileconfig
echo " \"database\": \"$database\"," >> $fileconfig
echo " \"user\": \"$user\"," >> $fileconfig
echo " \"password\": \"$password\"" >> $fileconfig
echo " }" >> $fileconfig
echo "}" >> $fileconfig
# End script
setcolor "\e[32m"
echo "Configuration completed!"
resetcolors
rm -rf configure