-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdeploy.sh
More file actions
executable file
·93 lines (75 loc) · 3.45 KB
/
deploy.sh
File metadata and controls
executable file
·93 lines (75 loc) · 3.45 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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
#!/bin/bash
# Deploy script for wispgpt.com
# Based on sushi server upload instructions
set -e # Exit on any error
# Configuration
DOMAIN="wispgpt.com"
SERVER_USER="root"
SERVER_IP="159.203.99.130"
REMOTE_PATH="/var/www/${DOMAIN}/public_html"
LOCAL_PATH="."
# Colors for output
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
NC='\033[0m' # No Color
echo -e "${GREEN}🚀 Starting deployment for ${DOMAIN}${NC}"
# Step 1: Create directory structure on server
echo -e "${YELLOW}📁 Creating directory structure...${NC}"
ssh ${SERVER_USER}@${SERVER_IP} "mkdir -p /var/www/${DOMAIN}/public_html"
# Step 2: Upload website files
echo -e "${YELLOW}📤 Uploading files...${NC}"
scp -r ${LOCAL_PATH}/*.html ${LOCAL_PATH}/src/ ${LOCAL_PATH}/wrangler.toml ${SERVER_USER}@${SERVER_IP}:${REMOTE_PATH}/
# Step 3: Set proper permissions
echo -e "${YELLOW}🔐 Setting permissions...${NC}"
ssh ${SERVER_USER}@${SERVER_IP} "chown -R www-data:www-data /var/www/${DOMAIN} && chmod -R 755 /var/www/${DOMAIN}/public_html && find /var/www/${DOMAIN}/public_html -type f -exec chmod 644 {} \;"
# Step 4: Create Apache virtual host (if it doesn't exist)
echo -e "${YELLOW}🌐 Configuring Apache virtual host...${NC}"
ssh ${SERVER_USER}@${SERVER_IP} << 'EOF'
if [ ! -f /etc/apache2/sites-available/wispgpt.com.conf ]; then
cat > /etc/apache2/sites-available/wispgpt.com.conf << 'APACHE_EOF'
<VirtualHost *:80>
ServerName wispgpt.com
ServerAlias www.wispgpt.com
ServerAdmin webmaster@wispgpt.com
DocumentRoot /var/www/wispgpt.com/public_html
ErrorLog ${APACHE_LOG_DIR}/wispgpt_error.log
CustomLog ${APACHE_LOG_DIR}/wispgpt_access.log combined
<Directory /var/www/wispgpt.com/public_html>
Options -Indexes +FollowSymLinks
AllowOverride All
Require all granted
</Directory>
RewriteEngine on
RewriteCond %{SERVER_NAME} =wispgpt.com [OR]
RewriteCond %{SERVER_NAME} =www.wispgpt.com
RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [END,NE,R=permanent]
</VirtualHost>
APACHE_EOF
echo "Apache virtual host created"
else
echo "Apache virtual host already exists"
fi
EOF
# Step 5: Enable site and reload Apache
echo -e "${YELLOW}✅ Enabling site and reloading Apache...${NC}"
ssh ${SERVER_USER}@${SERVER_IP} "a2ensite ${DOMAIN}.conf && systemctl reload apache2"
# Step 6: Test Apache configuration
echo -e "${YELLOW}🔧 Testing Apache configuration...${NC}"
ssh ${SERVER_USER}@${SERVER_IP} "apache2ctl configtest"
# Step 7: SSL certificate setup (optional, commented out)
# Uncomment the following lines if you want to automatically setup SSL
# echo -e "${YELLOW}🔒 Setting up SSL certificate...${NC}"
# ssh ${SERVER_USER}@${SERVER_IP} "certbot --apache -d ${DOMAIN} -d www.${DOMAIN} --non-interactive --agree-tos --email admin@${DOMAIN}"
echo -e "${GREEN}✅ Deployment completed successfully!${NC}"
echo -e "${GREEN}🌐 Your site should be available at: http://${DOMAIN}${NC}"
echo -e "${YELLOW}📝 Note: Run the SSL setup manually if needed:${NC}"
echo -e " ssh ${SERVER_USER}@${SERVER_IP} \"certbot --apache -d ${DOMAIN} -d www.${DOMAIN} --non-interactive --agree-tos --email admin@${DOMAIN}\""
# Optional: Test the website
echo -e "${YELLOW}🧪 Testing website...${NC}"
if curl -I http://${DOMAIN} 2>/dev/null | grep -q "200 OK"; then
echo -e "${GREEN}✅ Website is responding!${NC}"
else
echo -e "${RED}⚠️ Website may not be responding. Check DNS settings.${NC}"
fi
echo -e "${GREEN}🎉 Deployment script finished!${NC}"