1
0
Fork 0
mirror of https://github.com/seanmorley15/AdventureLog.git synced 2025-07-19 12:59:36 +02:00

Enhance AdventureLog installer with Docker container check; improve service readiness feedback and success message formatting.

This commit is contained in:
Sean Morley 2025-05-26 21:09:00 -04:00
parent bcd1f02131
commit d34a9001c0

View file

@ -23,6 +23,7 @@ readonly YELLOW='\033[1;33m'
readonly BLUE='\033[0;34m' readonly BLUE='\033[0;34m'
readonly PURPLE='\033[0;35m' readonly PURPLE='\033[0;35m'
readonly CYAN='\033[0;36m' readonly CYAN='\033[0;36m'
readonly MAGENTA='\033[0;35m'
readonly BOLD='\033[1m' readonly BOLD='\033[1m'
readonly NC='\033[0m' # No Color readonly NC='\033[0m' # No Color
@ -56,7 +57,7 @@ print_banner() {
║ ║ ║ ║
║ 🌍 A D V E N T U R E L O G I N S T A L L E R ║ ║ 🌍 A D V E N T U R E L O G I N S T A L L E R ║
║ ║ ║ ║
The Ultimate Self-Hosted Adventure Tracking Platform The Ultimate Travel Companion
║ ║ ║ ║
╚══════════════════════════════════════════════════════════════════════╝ ╚══════════════════════════════════════════════════════════════════════╝
EOF EOF
@ -207,6 +208,19 @@ create_directory() {
} }
} }
# Check for AdventureLog running as a docker container
check_running_container() {
if docker ps -a --filter "name=adventurelog" --format '{{.Names}}' | grep -q "adventurelog"; then
log_error "AdventureLog is already running as a Docker container (including stopped or restarting states)."
echo ""
echo "Running this installer further can break existing installs."
echo "Please stop and remove the existing AdventureLog container manually before proceeding."
echo " • To stop: docker compose down --remove-orphans"
echo "Installation aborted to prevent data loss."
exit 1
fi
}
download_files() { download_files() {
log_info "Downloading configuration files..." log_info "Downloading configuration files..."
@ -480,21 +494,47 @@ start_services() {
} }
wait_for_services() { wait_for_services() {
log_info "Waiting for services to be ready..." log_info "Waiting for services to be ready... (up to 90 seconds, first startup may take longer)"
local max_attempts=30 local max_attempts=45 # 45 attempts * 2 seconds = 90 seconds total
local attempt=1 local attempt=1
local frontend_ready=false
local backend_ready=false
while [ $attempt -le $max_attempts ]; do while [ $attempt -le $max_attempts ]; do
# Check frontend
if [ "$frontend_ready" = false ]; then
if curl -s -o /dev/null -w "%{http_code}" "$FRONTEND_ORIGIN" | grep -q "200\|404\|302"; then if curl -s -o /dev/null -w "%{http_code}" "$FRONTEND_ORIGIN" | grep -q "200\|404\|302"; then
log_success "Frontend is responding" log_success "Frontend is responding"
frontend_ready=true
fi
fi
# Check backend
if [ "$backend_ready" = false ]; then
if curl -s -o /dev/null -w "%{http_code}" "$BACKEND_URL" | grep -q "200\|404\|302"; then
log_success "Backend is responding"
backend_ready=true
fi
fi
# If both are ready, break the loop
if [ "$frontend_ready" = true ] && [ "$backend_ready" = true ]; then
break break
fi fi
# Check if we've reached max attempts
if [ $attempt -eq $max_attempts ]; then if [ $attempt -eq $max_attempts ]; then
if [ "$frontend_ready" = false ]; then
log_warning "Frontend may still be starting up (this is normal for first run)" log_warning "Frontend may still be starting up (this is normal for first run)"
fi
if [ "$backend_ready" = false ]; then
log_warning "Backend may still be starting up (this is normal for first run)"
fi
break break
fi fi
# Wait and increment counter
printf "." printf "."
sleep 2 sleep 2
((attempt++)) ((attempt++))
@ -512,48 +552,52 @@ print_success_message() {
echo "" echo ""
cat << 'EOF' cat << 'EOF'
╔══════════════════════════════════════════════════════════════════════╗ ╔════════════════════════════════════════════════════════════════════════════
║ ║ ║ ║
🎉 A D V E N T U R E L O G I N S T A L L E D ! 🚀 A D V E N T U R E L O G I S R E A D Y F O R L A U N C H!
║ ║ ║ ║
╚══════════════════════════════════════════════════════════════════════╝ ╚════════════════════════════════════════════════════════════════════════════
EOF EOF
echo "" echo ""
log_success "Installation completed successfully!" log_success "🎉 Installation completed successfully!"
echo "" echo ""
echo -e "${BOLD}📍 Access Points:${NC}" echo -e "${BOLD}🌐 Access Points:${NC}"
echo -e " 🌐 Frontend: ${CYAN}$FRONTEND_ORIGIN${NC}" echo -e " 🖥️ Frontend: ${CYAN}$FRONTEND_ORIGIN${NC}"
echo -e " 🔧 Backend: ${CYAN}$BACKEND_URL${NC}" echo -e " ⚙️ Backend: ${CYAN}$BACKEND_URL${NC}"
if [[ "$FRONTEND_ORIGIN" == *"localhost"* ]]; then
echo -e " 🏠 Local IP: ${CYAN}http://$ip_address:8015${NC}"
fi
echo "" echo ""
echo -e "${BOLD}🔐 Admin Credentials:${NC}" echo -e "${BOLD}🔐 Admin Credentials:${NC}"
echo -e " Username: ${GREEN}admin${NC}" echo -e " 👤 Username: ${GREEN}admin${NC}"
echo -e " Password: ${GREEN}$ADMIN_PASSWORD${NC}" echo -e " 🔑 Password: ${GREEN}$ADMIN_PASSWORD${NC}"
echo "" echo ""
echo -e "${BOLD}📁 Important Locations:${NC}" echo -e "${BOLD}📁 Important Locations:${NC}"
echo -e " Config: ${YELLOW}$(pwd)/.env${NC}" echo -e " 🛠️ Config: ${YELLOW}$(pwd)/.env${NC}"
echo -e " Data: ${YELLOW}adventurelog_media Docker volume${NC}" echo -e " 📦 Media Vol: ${YELLOW}adventurelog_media${NC}"
echo -e " Logs: ${YELLOW}docker compose logs -f${NC}" echo -e " 📜 Logs: ${YELLOW}docker compose logs -f${NC}"
echo "" echo ""
echo -e "${BOLD}🛠️ Management Commands:${NC}" echo -e "${BOLD}🧰 Management Commands:${NC}"
echo -e " Stop: ${CYAN}docker compose down${NC}" echo -e " Stop: ${CYAN}docker compose down${NC}"
echo -e " Start: ${CYAN}docker compose up -d${NC}" echo -e " ▶️ Start: ${CYAN}docker compose up -d${NC}"
echo -e " Update: ${CYAN}docker compose pull && docker compose up -d${NC}" echo -e " 🔄 Update: ${CYAN}docker compose pull && docker compose up -d${NC}"
echo -e " Logs: ${CYAN}docker compose logs -f${NC}" echo -e " 📖 Logs: ${CYAN}docker compose logs -f${NC}"
echo "" echo ""
log_info "Save your admin password in a secure location!" log_info "💾 Save your admin password in a secure location!"
echo "" echo ""
# Optional donation link
echo -e "${BOLD}❤️ Enjoying AdventureLog?${NC}"
echo -e " Support future development: ${MAGENTA}https://buymeacoffee.com/seanmorley15${NC}"
echo ""
echo -e "${BOLD}🌍 Adventure awaits — your journey starts now with AdventureLog!${NC}"
} }
print_failure_message() { print_failure_message() {
echo "" echo ""
log_error "Installation failed!" log_error "Installation failed!"
@ -592,6 +636,7 @@ main() {
print_header print_header
check_dependencies check_dependencies
check_docker_status check_docker_status
check_running_container
create_directory create_directory
download_files download_files
prompt_configuration prompt_configuration