-
Notifications
You must be signed in to change notification settings - Fork 0
/
shipit.sh
executable file
·56 lines (45 loc) · 2.56 KB
/
shipit.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
49
50
51
52
53
54
55
56
#!/usr/bin/env bash
echo "Har du stoppet node-app på server?"
select yn in "ja" "nei"; do
case $yn in
ja ) echo "Fint, da kjører vi på!"; break;;
nei ) echo "Stopp app på server og prøv igjen!"; exit;;
esac
done
echo "================================================================================================================="
echo " Bygger frontend for production (NODE_ENV=production) slik at API-kall går til notearkiv.tjk.no... "
echo "================================================================================================================="
cd frontend
npm run build # bygger med NODE_ENV=production
echo "================================================================================================================="
echo " Lager tgz-filer for overføring... "
echo "================================================================================================================="
cd ..
tar -zcvf server.tgz *.js *.json routes
echo ""
tar -zcvf frontend-dist.tgz frontend/dist
echo "================================================================================================================="
echo "Laster opp til server..."
echo "================================================================================================================="
#scp -P 7822 server.tgz frontend-dist.tgz [email protected]:/home/tjkno/tmp
scp -P 7822 server.tgz frontend-dist.tgz [email protected]:/home/tjkno/tmp
echo "================================================================================================================="
echo "Tar backup og Pakker ut på server..."
echo "================================================================================================================="
ssh -p 7822 [email protected] <<'ENDSSH'
# commands to run on remote host
echo "tjk.no server: Lager backup av gjeldende versjon..."
tar -zcvf noter-backup-$(date +%Y-%m-%d_%H%M).tgz notearkiv-server/*.js notearkiv-server/frontend notearkiv-server/routes
echo "tjk.no server: Fjerner gjeldende versjon. NB! Lar node_modules ligge!"
cd notearkiv-server
rm -r *.js *.json frontend routes
echo "tjk.no server: Pakker ut fra opplastet ny versjon..."
tar -zxvf ../tmp/server.tgz
tar -zxvf ../tmp/frontend-dist.tgz
ENDSSH
echo "================================================================================================================="
echo " Rydder opp..."
echo "================================================================================================================="
rm server.tgz frontend-dist.tgz
echo ""
echo "Ferdig."