-
-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathdeploy_web_app.sh
executable file
·44 lines (35 loc) · 1.07 KB
/
deploy_web_app.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
#!/usr/bin/env bash
#
# this script deploys the dist folder to the RPI server
#
WEBROOT="/var/www/html/skies-adsb"
source src/.env
if [ -z "$SKIES_ADSB_RPI_USERNAME" ] || [ -z "$SKIES_ADSB_RPI_HOST" ]; then
echo "Error: Required environment variables are not set"
echo "Please set SKIES_ADSB_RPI_USERNAME and SKIES_ADSB_RPI_HOST"
exit 1
fi
RPI_TARGET=$SKIES_ADSB_RPI_USERNAME@$SKIES_ADSB_RPI_HOST
echo "Deploy to: $RPI_TARGET"
echo "Creating dist.tar..."
tar cf dist.tar -C dist .
echo "Copying dist.tar to $RPI_TARGET:~"
scp dist.tar $RPI_TARGET:~
echo "Deploying dist.tar to $RPI_TARGET:$WEBROOT"
ssh $RPI_TARGET "
echo ' Removing old webroot...' &&
sudo rm -rf $WEBROOT || true &&
echo ' Creating new webroot...' &&
sudo mkdir -p $WEBROOT &&
echo ' Changing to webroot...' &&
cd $WEBROOT &&
echo ' Extracting new files...' &&
sudo tar xf ~/dist.tar . &&
echo ' Cleaning up temporary files...' &&
cd &&
rm dist.tar &&
echo ' Restarting web server...' &&
sudo service lighttpd restart
"
echo "Cleaning up local files..."
rm dist.tar