-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy paths
executable file
·57 lines (50 loc) · 1.55 KB
/
s
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
52
53
54
55
56
57
#!/usr/bin/env bash
REMOTE_DIR="~/"
# Function to display the script's usage
usage() {
echo "The script syncs the script directory with a remote directory"
echo "Usage: [--remote_dir </path/to/remote/dir>]"
echo "If no remote directory is specified, we sync with the default remote directory: $REMOTE_DIR"
echo "Usage: need to run as ./s [--remote_dir </path/to/remote/dir>] ..."
echo " --remote_dir : Remote directory to sync the current directory to. Example --remote_dir /path/to/remote/dir"
}
parse_args() {
# Loop through the remaining arguments
while [[ $# -gt 0 ]]; do
case "$1" in
--remote_dir)
if [[ $# -gt 1 ]]; then
REMOTE_DIR="$2" # Assign the value to IS_DEBUG
shift # Consume the value
else
echo "Error: Missing value for $1. Example usage: --remote_dir /path/to/remote/dir"
exit 1
fi
;;
--help)
# Display usage information
usage
exit 0
;;
*)
# Handle unknown arguments here if needed
echo "Unknown argument: $1"
usage
exit 1
;;
esac
shift
done
}
# Parse command-line arguments
parse_args "$@"
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" &>/dev/null && pwd)"
if [ -f .env ]; then
# Load Environment Variables
export "$(cat .env | grep -v '#' | awk '/=/ {print $1}')"
else
echo "Missing .env file"
exit 0
fi
echo "Syncing $SCRIPT_DIR to host: $BUILD_SERVER:$REMOTE_DIR"
rsync -avh --delete --exclude target $SCRIPT_DIR "$BUILD_SERVER":"$REMOTE_DIR"