-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathplanify.sh
39 lines (34 loc) · 1.14 KB
/
planify.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
#!/bin/bash
PATH=$PATH:/usr/local/go/bin
cd /home/planify
SHAONESUM=$(sha1sum api/database/01-tables.sql)
GITRES=$(git pull)
echo $GITRES
if [ "$GITRES" != "Already up to date." ];
then
echo "Updates detected"
SHATWOSUM=$(sha1sum api/database/01-tables.sql)
if [ "$SHAONESUM" != "$SHATWOSUM" ];
then
if [ -f .env ]; then
export $(echo $(cat .env | sed 's/#.*//g'| xargs) | envsubst)
fi
DB_HOST=${DB_HOST:0:len-1}
DB_USER=${DB_USER:0:len-1}
DB_PASSWORD=${DB_PASSWORD:0:len-1}
DB_NAME=${DB_NAME:0:len-1}
echo "Migration file changed, recreating database..."
mysql -h$DB_HOST -u$DB_USER -p$DB_PASSWORD $DB_NAME < api/database/02-tables.down.sql
mysql -h$DB_HOST -u$DB_USER -p$DB_PASSWORD $DB_NAME < api/database/01-tables.sql
echo "Migration finished"
fi
echo "Building app..."
screen -S planify -p 0 -X stuff "^C"
screen -S planify -p 0 -X stuff "rm planifyApp && cd api && go build -v -o ../planifyApp . ^M"
screen -S planify -p 0 -X stuff "cd ../ && chmod +x planifyApp ^M"
screen -S planify -p 0 -X stuff "./planifyApp^M"
sleep 3
echo "Build finished"
else
echo "App is up to date, exiting"
fi