-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathserverpush.sh
More file actions
executable file
·51 lines (42 loc) · 1.1 KB
/
serverpush.sh
File metadata and controls
executable file
·51 lines (42 loc) · 1.1 KB
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
#!/bin/bash
GREEN="\033[0;32m"
REGULAR="\033[0m"
SOURCE_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
VARIABLES="${SOURCE_DIR}/.env"
# Load or prompt for REMOTE_USER
if [[ -f "$VARIABLES" ]]; then
source "$VARIABLES"
fi
if [[ -z "$REMOTE_USER" ]]; then
read -p "Enter your remote username: " REMOTE_USER
echo "REMOTE_USER=\"$REMOTE_USER\"" >> "$VARIABLES"
fi
# Resolve path to the script
DEST_DIR="Nodetalk"
PROXY="melkki.cs.helsinki.fi"
DESTINATION="svm-11.cs.helsinki.fi"
# Files not to be uploaded to the servers
EXCLUDES=(
"--exclude=__pycache__"
"--exclude=.git*"
"--exclude=README.md"
"--exclude=.venv"
"--exclude=$(basename "$0")"
"--exclude=start.sh"
"--exclude=stop.sh"
"--exclude=tunnel.sh"
"--exclude=pid_svm-11*"
)
# Sync command
update-nd () {
rsync -avz \
"${EXCLUDES[@]}" \
-e "ssh -J ${REMOTE_USER}@${PROXY}" \
"$SOURCE_DIR/" \
"${REMOTE_USER}@${DESTINATION}:${DEST_DIR}/"
}
# Run rsync for all nodes
for DESTINATION in svm-11{,-2,-3}.cs.helsinki.fi; do
echo -e "${GREEN}updating${REGULAR} $DESTINATION..."
update-nd
done