-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathacropolis.sh
More file actions
executable file
·264 lines (220 loc) · 8.37 KB
/
Copy pathacropolis.sh
File metadata and controls
executable file
·264 lines (220 loc) · 8.37 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
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
#!/usr/bin/env bash
# =============================================================================
# Acropolis CLI — Enterprise Foundation for Parthenon
# =============================================================================
# Usage:
# ./acropolis.sh up [--edition community|enterprise]
# ./acropolis.sh down
# ./acropolis.sh status
# ./acropolis.sh logs [service]
# ./acropolis.sh init
# ./acropolis.sh backup
# ./acropolis.sh smoke-test
# =============================================================================
set -euo pipefail
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
cd "$SCRIPT_DIR"
# Colors
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
BLUE='\033[0;34m'
CYAN='\033[0;36m'
NC='\033[0m'
# Load .env if present
if [[ -f .env ]]; then
set -a
source .env
set +a
fi
EDITION="${ACROPOLIS_EDITION:-community}"
DOMAIN="${DOMAIN:-acumenus.net}"
NETWORK_NAME="acropolis_network"
# ── Helpers ─────────────────────────────────────────────────────────────────
log_info() { echo -e "${BLUE}[acropolis]${NC} $*"; }
log_ok() { echo -e "${GREEN}[acropolis]${NC} $*"; }
log_warn() { echo -e "${YELLOW}[acropolis]${NC} $*"; }
log_error() { echo -e "${RED}[acropolis]${NC} $*"; }
compose_files() {
local edition="${1:-$EDITION}"
local files="-f docker-compose.yml -f docker-compose.community.yml"
if [[ "$edition" == "enterprise" ]]; then
files="$files -f docker-compose.enterprise.yml"
fi
echo "$files"
}
ensure_network() {
if ! docker network inspect "$NETWORK_NAME" &>/dev/null; then
log_info "Creating Docker network: $NETWORK_NAME"
docker network create "$NETWORK_NAME"
fi
}
check_license() {
if [[ "$1" == "enterprise" ]]; then
if [[ -z "${ACROPOLIS_LICENSE_KEY:-}" ]]; then
log_warn "No ACROPOLIS_LICENSE_KEY set. Enterprise features require a valid license."
log_warn "Set ACROPOLIS_LICENSE_KEY in .env or contact sales@acumenus.net"
read -p "Continue without license validation? [y/N] " -n 1 -r
echo
if [[ ! $REPLY =~ ^[Yy]$ ]]; then
exit 1
fi
fi
fi
}
# ── Commands ────────────────────────────────────────────────────────────────
cmd_init() {
log_info "Initializing Acropolis..."
# Copy .env if needed
if [[ ! -f .env ]]; then
cp .env.example .env
log_ok "Created .env from .env.example — edit it with your settings"
fi
# Create network
ensure_network
# Create ACME directory
mkdir -p traefik/acme
touch traefik/acme/acme.json
chmod 600 traefik/acme/acme.json
# Create workflow directory
mkdir -p config/n8n/workflows
log_ok "Initialization complete. Run: ./acropolis.sh up"
}
cmd_up() {
local edition="$EDITION"
# Parse args
while [[ $# -gt 0 ]]; do
case "$1" in
--edition) edition="$2"; shift 2 ;;
--community) edition="community"; shift ;;
--enterprise) edition="enterprise"; shift ;;
*) shift ;;
esac
done
check_license "$edition"
ensure_network
local files
files=$(compose_files "$edition")
log_info "Starting Acropolis (${CYAN}$edition${NC} edition)..."
eval "docker compose $files up -d"
echo
log_ok "Acropolis is running!"
echo
cmd_urls "$edition"
}
cmd_down() {
local files
files=$(compose_files "enterprise") # Include all files to ensure everything stops
log_info "Stopping Acropolis..."
eval "docker compose $files down"
log_ok "Acropolis stopped."
}
cmd_status() {
local files
files=$(compose_files "enterprise")
echo -e "${CYAN}═══════════════════════════════════════════════════════════${NC}"
echo -e "${CYAN} Acropolis Platform Status${NC}"
echo -e "${CYAN}═══════════════════════════════════════════════════════════${NC}"
echo
eval "docker compose $files ps --format 'table {{.Name}}\t{{.Status}}\t{{.Ports}}'" 2>/dev/null || true
echo
echo -e "${BLUE}Edition:${NC} ${EDITION}"
echo -e "${BLUE}Domain:${NC} ${DOMAIN}"
}
cmd_logs() {
local files
files=$(compose_files "enterprise")
local service="${1:-}"
if [[ -n "$service" ]]; then
eval "docker compose $files logs -f $service"
else
eval "docker compose $files logs -f --tail=100"
fi
}
cmd_urls() {
local edition="${1:-$EDITION}"
echo -e "${CYAN}Community Services:${NC}"
echo -e " Traefik Dashboard ${GREEN}https://$DOMAIN:${TRAEFIK_DASHBOARD_PORT:-8090}${NC}"
echo -e " Portainer ${GREEN}https://portainer.$DOMAIN${NC}"
echo -e " pgAdmin ${GREEN}https://pgadmin.$DOMAIN${NC}"
echo -e " Grafana ${GREEN}https://grafana.$DOMAIN${NC}"
if [[ "$edition" == "enterprise" ]]; then
echo
echo -e "${CYAN}Enterprise Services:${NC}"
echo -e " n8n ${GREEN}https://n8n.$DOMAIN${NC}"
echo -e " Superset ${GREEN}https://superset.$DOMAIN${NC}"
echo -e " DataHub ${GREEN}https://datahub.$DOMAIN${NC}"
echo -e " Authentik ${GREEN}https://auth.$DOMAIN${NC}"
fi
echo
echo -e "${CYAN}Parthenon:${NC}"
echo -e " Application ${GREEN}https://parthenon.$DOMAIN${NC}"
}
cmd_backup() {
local backup_dir="backups/$(date +%Y%m%d-%H%M%S)"
mkdir -p "$backup_dir"
log_info "Backing up Acropolis data to $backup_dir..."
# Backup volume list
local volumes=(portainer_data pgadmin_data grafana_data prometheus_data loki_data)
for vol in "${volumes[@]}"; do
local full_vol
full_vol=$(docker volume ls --format '{{.Name}}' | grep "$vol" | head -1)
if [[ -n "$full_vol" ]]; then
log_info " Backing up $full_vol..."
docker run --rm -v "$full_vol":/data -v "$(pwd)/$backup_dir":/backup \
alpine tar czf "/backup/${vol}.tar.gz" /data 2>/dev/null || true
fi
done
log_ok "Backup complete: $backup_dir"
}
cmd_smoke_test() {
log_info "Running smoke tests..."
if [[ -f tests/smoke-test.sh ]]; then
bash tests/smoke-test.sh
else
log_error "No smoke test found at tests/smoke-test.sh"
exit 1
fi
}
cmd_help() {
echo -e "${CYAN}Acropolis — Enterprise Foundation for Parthenon${NC}"
echo
echo "Usage: ./acropolis.sh <command> [options]"
echo
echo "Commands:"
echo " init Initialize Acropolis (create .env, network, dirs)"
echo " up [--edition TYPE] Start services (community|enterprise)"
echo " down Stop all services"
echo " status Show service status"
echo " logs [service] Follow logs (all or specific service)"
echo " urls Show service URLs"
echo " backup Backup all volume data"
echo " smoke-test Run health checks on all services"
echo " help Show this help"
echo
echo "Options:"
echo " --edition community Start Community Edition (default)"
echo " --edition enterprise Start Enterprise Edition (requires license)"
echo
echo "Examples:"
echo " ./acropolis.sh init"
echo " ./acropolis.sh up --edition enterprise"
echo " ./acropolis.sh logs grafana"
}
# ── Main ────────────────────────────────────────────────────────────────────
case "${1:-help}" in
init) cmd_init ;;
up) shift; cmd_up "$@" ;;
down) cmd_down ;;
status) cmd_status ;;
logs) shift; cmd_logs "$@" ;;
urls) cmd_urls ;;
backup) cmd_backup ;;
smoke-test) cmd_smoke_test ;;
help|--help|-h) cmd_help ;;
*)
log_error "Unknown command: $1"
cmd_help
exit 1
;;
esac