Repository navigation
Expand file tree
/
Copy pathdeploy.sh
More file actions
executable file
·69 lines (60 loc) · 1.86 KB
/
Copy pathdeploy.sh
File metadata and controls
executable file
·69 lines (60 loc) · 1.86 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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
#!/bin/bash
#
# Simple deployment script to copy src and public folders to a remote server
# Uses rsync for efficient incremental transfers
#
# Usage:
# ./deploy.sh # Uses defaults (user@host and path from script)
# ./deploy.sh user@host # Uses provided host, default path
# ./deploy.sh user@host /path # Uses provided host and path
#
# Defaults (edit these for your environment):
# REMOTE_USER="deploy"
# REMOTE_HOST="example.com"
# REMOTE_PATH="/var/www/phuppi"
set -e
# Default values - edit these to match your server
REMOTE_USER="deploy"
REMOTE_HOST="example.com"
REMOTE_PATH="/var/www/phuppi"
# Parse command line arguments
case "$#" in
0)
# Use defaults - no arguments provided
;;
1)
REMOTE_HOST="$1"
;;
2)
REMOTE_HOST="$1"
REMOTE_PATH="$2"
;;
*)
echo "Usage: $0 [user@host] [remote_path]"
echo " If no arguments provided, uses defaults in the script"
echo " If only host provided, uses default path"
exit 1
;;
esac
# Parse user@host format if provided
if [[ "$REMOTE_HOST" == *"@"* ]]; then
REMOTE_USER="${REMOTE_HOST%%@*}"
REMOTE_HOST="${REMOTE_HOST#*@}"
fi
echo "Deploying to ${REMOTE_USER}@${REMOTE_HOST}:${REMOTE_PATH}"
echo ""
# Rsync options:
# -a: archive mode (preserves permissions, timestamps, etc.)
# -z: compress data during transfer
# -h: human-readable output
# --delete: remove files in destination that don't exist in source
# --progress: show progress during transfer
RSYNC_OPTS="-azh --delete --progress"
# Copy src folder
echo "Syncing src folder..."
rsync $RSYNC_OPTS ./src/ "${REMOTE_USER}@${REMOTE_HOST}:${REMOTE_PATH}/src/"
# Copy public folder
echo "Syncing public folder..."
rsync $RSYNC_OPTS ./public/ "${REMOTE_USER}@${REMOTE_HOST}:${REMOTE_PATH}/public/"
echo ""
echo "Deployment complete!"