-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdev.sh
executable file
·51 lines (45 loc) · 1.37 KB
/
dev.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
#!/bin/bash
# Set default values
DEFAULT_USERNAME="orangepi"
DEFAULT_DEST_DIR="/home/orangepi/Orangead/player"
# If command-line arguments are provided, use them. Otherwise, ask for input.
if [ -n "$1" ]; then
USERNAME=$1
else
read -p "Enter remote device username (default: $DEFAULT_USERNAME): " USERNAME
USERNAME=${USERNAME:-$DEFAULT_USERNAME}
fi
if [ -n "$2" ]; then
IP=$2
else
read -p "Enter remote device IP: " IP
fi
# Determine the directory of the script
DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
# If both username and IP are given, run the rsync command
if [ -n "$USERNAME" ] && [ -n "$IP" ]; then
# Set the destination path
DEST="$USERNAME@$IP:$DEFAULT_DEST_DIR"
# Run the rsync command with --delete option and exclusions
rsync -av -e ssh --progress \
--delete \
--exclude='.DS_Store' \
--exclude='README.md' \
--exclude='.git/' \
--exclude='.gitignore' \
--exclude='dev.sh' \
--exclude='config/' \
--exclude='prod/' \
--exclude='preprod/' \
--exclude='staging/' \
--exclude='logs/*' \
--exclude='api/.venv/' \
--exclude='**/__pycache__/' \
--exclude='**/*.pyc' \
--exclude='**/*.pyo' \
--include='logs/.placeholder' \
"$DIR/" "$DEST"
else
echo "Both username and IP must be provided!"
exit 1
fi