Skip to content

Commit 2750f75

Browse files
committed
feat: add rsync installer for Windows users
1 parent 28aa39f commit 2750f75

1 file changed

Lines changed: 80 additions & 0 deletions

File tree

lib/rsync-installer.sh

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
#!/usr/bin/env bash
2+
#
3+
# rsync-installer.sh - Rsync installer for Windows
4+
#
5+
# Ensures rsync is available on Windows systems by installing it via Git for Windows
6+
#
7+
8+
# Check if rsync is available
9+
has_rsync() {
10+
command -v rsync &> /dev/null
11+
}
12+
13+
# Check if Git for Windows is installed
14+
has_git_for_windows() {
15+
command -v git &> /dev/null && [[ "$OSTYPE" == "msys" || "$OSTYPE" == "cygwin" ]]
16+
}
17+
18+
# Install rsync on Windows
19+
install_rsync_windows() {
20+
info "Checking rsync availability on Windows..."
21+
22+
if has_rsync; then
23+
success "rsync is already available ($(rsync --version | head -n1))"
24+
return 0
25+
fi
26+
27+
warn "rsync is not installed on your system"
28+
29+
# Check if Git for Windows is available
30+
if has_git_for_windows; then
31+
info "Git for Windows is installed but rsync is missing"
32+
info "rsync should be included in Git for Windows by default"
33+
warn "Try running this command from Git Bash instead of Command Prompt/PowerShell"
34+
error "Please run ShipNode from Git Bash to access rsync"
35+
fi
36+
37+
# Git for Windows not found
38+
warn "rsync is required for deployment"
39+
echo ""
40+
echo "To install rsync on Windows, you have two options:"
41+
echo ""
42+
echo "Option 1: Git for Windows (Recommended)"
43+
echo " 1. Download from: https://git-scm.com/download/win"
44+
echo " 2. Run the installer (includes rsync)"
45+
echo " 3. Use Git Bash to run ShipNode"
46+
echo ""
47+
echo "Option 2: WSL (Windows Subsystem for Linux)"
48+
echo " 1. Open PowerShell as Administrator"
49+
echo " 2. Run: wsl --install"
50+
echo " 3. Restart your computer"
51+
echo " 4. In WSL terminal: sudo apt install rsync"
52+
echo " 5. Use WSL terminal to run ShipNode"
53+
echo ""
54+
55+
error "Please install rsync and try again"
56+
}
57+
58+
# Ensure rsync is available (cross-platform)
59+
ensure_rsync() {
60+
# Detect OS
61+
local os_info
62+
IFS='|' read -r os_info _ <<< "$(detect_os)"
63+
64+
# Check if rsync is available
65+
if has_rsync; then
66+
return 0
67+
fi
68+
69+
# Only attempt installation on Windows
70+
if [ "$os_info" = "windows" ]; then
71+
install_rsync_windows
72+
else
73+
# On Linux/macOS, just error with instructions
74+
error "rsync is not installed. Please install it:
75+
Linux: sudo apt install rsync (Ubuntu/Debian)
76+
sudo yum install rsync (RHEL/CentOS)
77+
sudo dnf install rsync (Fedora)
78+
macOS: rsync is pre-installed (check if Xcode CLI tools are installed)"
79+
fi
80+
}

0 commit comments

Comments
 (0)