-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix debug printing config on start, add a sync_to_host script
- Loading branch information
1 parent
d88f13a
commit 0e7d04e
Showing
2 changed files
with
44 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
#!/usr/bin/env bash | ||
|
||
# Define the target directory | ||
USER_NAME="wojciech-sromek" | ||
TARGET_DIR="/home/ubuntu/${USER_NAME}" | ||
|
||
# Define the hosts, order is important, indices are used to identify .env files | ||
TARGET_HOSTS=( | ||
"[email protected]" | ||
"[email protected]" | ||
"[email protected]" | ||
) | ||
|
||
# Define the directories to exclude | ||
EXCLUDE_DIRS=(".idea" ".git" "target") | ||
|
||
# Create the exclude options for rsync | ||
EXCLUDE_OPTIONS=() | ||
for EXCLUDE_DIR in "${EXCLUDE_DIRS[@]}"; do | ||
EXCLUDE_OPTIONS+=("--exclude=$EXCLUDE_DIR") | ||
done | ||
|
||
# Get the name of the current working directory | ||
CURRENT_DIR_NAME=$(basename "$PWD") | ||
|
||
## Loop through each host using an index, starting with 1 | ||
for i in "${!TARGET_HOSTS[@]}"; do | ||
INDEX=$((i + 1)) | ||
HOST=${TARGET_HOSTS[$i]} | ||
echo "Syncing $CURRENT_DIR_NAME to $HOST:$TARGET_DIR (Target Host $INDEX)" | ||
|
||
## Make sure that the correct environment file is copied to the correct host | ||
cp .env.mpc$INDEX.dist .env | ||
|
||
## Sync the current directory to the target host | ||
rsync -avz --delete "${EXCLUDE_OPTIONS[@]}" "$PWD" "$HOST:$TARGET_DIR" | ||
if [ $? -eq 0 ]; then | ||
echo "Sync to $HOST completed successfully." | ||
else | ||
echo "Sync to $HOST failed." | ||
fi | ||
done |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters