-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrun.sh
executable file
·48 lines (36 loc) · 1.25 KB
/
run.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
#!/bin/bash
CUR_PATH=$(pwd)
echo "This script will install the required dependencies for the project."
# Read the .env file and export the variables
while IFS== read -r key value; do
printf -v "$key" %s "$value" && export "$key"
done <.env
echo "Environment variables exported."
echo "Creating mysql database."
mysql -h "$DB_HOST" -P "$DB_PORT" -u "$DB_USER" -p"$DB_PASSWORD" < init.sql
echo "Database created."
make migration_up
echo "Downloading apache2 and setting up a virtual host."
sudo apt update && sudo apt-get install apache2 -y
sudo a2enmod proxy proxy_http
cd /etc/apache2/sites-available
sudo mkdir -p /var/log/apache2/
sudo chmod -R 744 /var/log/apache2/
sudo sh -c 'echo "<VirtualHost *:80>
ServerName libralynx.org
ServerAdmin [email protected]
ProxyPreserveHost On
ProxyPass / http://127.0.0.1:'$APP_PORT'/
ProxyPassReverse / http://127.0.0.1:'$APP_PORT'/
TransferLog /var/log/apache2/libralynx_access.log
ErrorLog /var/log/apache2/libralynx_error.log
</VirtualHost>" > libralynx.org.conf'
sudo a2ensite libralynx.org.conf
sudo sh -c 'echo "127.0.0.1 libralynx.org" >> /etc/hosts'
sudo a2dissite 000-default.conf
sudo apache2ctl configtest
sudo systemctl restart apache2
echo "Starting the server..."
cd $CUR_PATH
go mod tidy
make