-
Notifications
You must be signed in to change notification settings - Fork 0
/
installer
74 lines (50 loc) · 1.18 KB
/
installer
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
#!/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[36m"
echo "Welcome to chat installer"
resetcolors
checkroot
# Save in vars the mysql credentials
read -p "MySQL user: " user
read -p "MySQL password: " password
read -p "MySQL host: " host
# Create the credentials for mysql in temp file
touch mysql.credentials
echo "[client]" >> mysql.credentials
echo "user = $user" >> mysql.credentials
echo "password = $password" >> mysql.credentials
echo "host = $host" >> mysql.credentials
# Create the chat database
mysql --defaults-extra-file=./mysql.credentials < assets/sql/init.sql
# Remove the temp files
rm -rf mysql.credentials
# Install node dependencies
npm install
# Create script for start nodejs
touch start
chmod 755 start
echo "#!/bin/bash" >> start
echo "echo 'Starting server...' && sleep 1" >> start
echo "npm start" >> start
# Print the installation finished
setcolor "\e[32m"
echo "Installation completed!"
resetcolors
# Remove temp installer
rm -rf installer