-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdeploy_to_pi.sh
executable file
·36 lines (29 loc) · 1.15 KB
/
deploy_to_pi.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
#!/bin/bash
# Bash script to deploy files to a Raspberry Pi running a Flask app
# Configuration
LOCAL_DIR="$(pwd)" # Assumes you're running this script from your project directory
REMOTE_USER="pi"
REMOTE_HOST="raspberrypi" # Or use the IP address of your Raspberry Pi
REMOTE_DIR="/home/pi/dinkydash"
# Ensure the remote directory exists
ssh $REMOTE_USER@$REMOTE_HOST "mkdir -p $REMOTE_DIR"
# Use rsync to copy files, excluding .venv, .git, and other unnecessary files
rsync -avz --exclude='venv' \
--exclude='.git' \
--exclude='__pycache__' \
--exclude='*.pyc' \
--exclude='*.pyo' \
--exclude='*.pyd' \
--exclude='*.log' \
--exclude='*.swp' \
--exclude='*.idea' \
"$LOCAL_DIR/" "$REMOTE_USER@$REMOTE_HOST:$REMOTE_DIR/"
# If successful, print a success message
if [ $? -eq 0 ]; then
echo "Files successfully copied to Raspberry Pi"
else
echo "Error occurred while copying files"
fi
# Optionally, restart the Flask service on the Raspberry Pi
ssh $REMOTE_USER@$REMOTE_HOST "sudo systemctl restart dinkydash.service"
echo "Flask service restarted on Raspberry Pi"