-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdeploy.sh
More file actions
executable file
·51 lines (42 loc) · 1.24 KB
/
deploy.sh
File metadata and controls
executable file
·51 lines (42 loc) · 1.24 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
#!/bin/bash
# Configuration
# Read from .env file if it exists
if [ -f .env.deploy ]; then
source .env.deploy
fi
FTP_HOST=${FTP_HOST:-""}
FTP_USER=${FTP_USER:-""}
FTP_PASS=${FTP_PASS:-""}
REMOTE_DIR=${REMOTE_DIR:-"/public_html"}
if [ -z "$FTP_HOST" ] || [ -z "$FTP_USER" ]; then
echo "Missing configuration!"
echo "Please set FTP_HOST and FTP_USER variables in a .env.deploy file"
echo "Example .env.deploy content:"
echo " FTP_HOST=\"your-ftp-host.com\""
echo " FTP_USER=\"your-username\""
echo " FTP_PASS=\"your-password\""
echo " REMOTE_DIR=\"/public_html\""
exit 1
fi
if [ -z "$FTP_PASS" ]; then
read -sp "Enter FTP password for $FTP_USER: " FTP_PASS
echo ""
fi
# Check if lftp is installed
if ! command -v lftp &> /dev/null; then
echo "Error: 'lftp' is not installed. Please install it first."
echo "On Ubuntu/Debian: sudo apt install lftp"
exit 1
fi
echo "Building application..."
npm run build
echo "Setting permissions for static files..."
chmod -R 755 dist
find dist -type f -exec chmod 644 {} \;
echo "Syncing static files to $FTP_HOST..."
lftp -u "$FTP_USER","$FTP_PASS" "$FTP_HOST" <<EOF
set ssl:verify-certificate no
mirror -R -p dist/ "$REMOTE_DIR"
bye
EOF
echo "Deployment finished!"