-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdeploy-ghost-sqlite.sh
More file actions
executable file
·107 lines (91 loc) · 2.99 KB
/
deploy-ghost-sqlite.sh
File metadata and controls
executable file
·107 lines (91 loc) · 2.99 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
94
95
96
97
98
99
100
101
102
103
104
105
106
107
#!/bin/bash
# Deploy Ghost CMS with SQLite to Nomad
# Simplified deployment without PostgreSQL, using SQLite and Mailcow
set -e
echo "🚀 Ghost CMS Deployment (SQLite + Mailcow)"
echo "=========================================="
# Check if .env file exists
if [ ! -f .env ]; then
echo "❌ .env file not found!"
echo "Creating from Mailcow template..."
cp .env.mailcow .env
echo "⚠️ Please edit .env with your Mailcow SMTP settings and run again"
exit 1
fi
# Load environment variables
source .env
# Check required mail variables
if [ -z "$MAIL_HOST" ] || [ "$MAIL_HOST" = "mail.yourdomain.com" ]; then
echo "❌ MAIL_HOST not configured in .env file!"
echo "Please set your Mailcow SMTP host"
exit 1
fi
if [ -z "$MAIL_PASSWORD" ] || [ "$MAIL_PASSWORD" = "your_mailcow_password" ]; then
echo "❌ MAIL_PASSWORD not set in .env file!"
echo "Please set your Mailcow SMTP password"
exit 1
fi
# Check if Nomad is running
if ! nomad status > /dev/null 2>&1; then
echo "❌ Nomad is not running or not accessible"
echo "Start Nomad with: sudo nomad agent -dev"
exit 1
fi
# Check if Consul is running
if ! consul catalog services > /dev/null 2>&1; then
echo "⚠️ Consul is not running. Starting in dev mode..."
consul agent -dev > /tmp/consul.log 2>&1 &
sleep 5
fi
# Setup volumes
VOLUME_BASE="/opt/nomad/volumes"
if [ ! -d "${VOLUME_BASE}/ghost-data" ]; then
echo "🔧 Setting up Ghost data volume..."
sudo mkdir -p "${VOLUME_BASE}/ghost-data"
sudo chown -R 1000:1000 "${VOLUME_BASE}/ghost-data"
sudo chmod -R 755 "${VOLUME_BASE}/ghost-data"
echo "✅ Volume created at ${VOLUME_BASE}/ghost-data"
fi
# Store mail credentials in Consul
echo ""
echo "📦 Storing mail configuration in Consul..."
consul kv put ghost/mail/user "$MAIL_USER"
consul kv put ghost/mail/password "$MAIL_PASSWORD"
# Deploy the job
echo ""
echo "🔄 Deploying Ghost CMS..."
nomad job run nomad/ghost-sqlite.nomad
echo "⏳ Waiting for deployment..."
sleep 10
# Get job status
echo ""
echo "📊 Job Status:"
nomad job status ghost-cms
# Get allocation ID
ALLOC_ID=$(nomad job status ghost-cms | grep -A2 "Allocations" | tail -1 | awk '{print $1}')
if [ ! -z "$ALLOC_ID" ]; then
echo ""
echo "📋 Allocation ID: $ALLOC_ID"
echo ""
echo "🔍 To view logs:"
echo " nomad alloc logs -f $ALLOC_ID ghost"
fi
echo ""
echo "✅ Deployment completed!"
echo ""
echo "🌐 Ghost is available at:"
echo " http://localhost:8009 (direct access)"
echo " https://cybermonkey.net.au (via Caddy reverse proxy)"
echo ""
echo "📧 Mail configuration:"
echo " SMTP Host: $MAIL_HOST"
echo " SMTP User: $MAIL_USER"
echo " From Address: $MAIL_FROM"
echo ""
echo "💾 Data location: ${VOLUME_BASE}/ghost-data"
echo " SQLite DB: ${VOLUME_BASE}/ghost-data/data/ghost.db"
echo ""
echo "📝 Next steps:"
echo "1. Access Ghost admin at http://localhost:8009/ghost"
echo "2. Complete the setup wizard"
echo "3. Configure your Caddy reverse proxy to forward to port 8009"