Build [v1.9.10] (Access & SSL Recovery: Fixed Admin info and Explicit IP Proxy)
This commit is contained in:
72
deploy.sh
72
deploy.sh
@@ -1,30 +1,60 @@
|
||||
#!/bin/bash
|
||||
# deploy.sh - Production Deployment Script for TFM aInventory
|
||||
# Forces Docker Compose to use the inventory.env file for both host and container.
|
||||
# =============================================================================
|
||||
# TFM aInventory - Bulletproof Deployment Script (v1.9.10)
|
||||
# =============================================================================
|
||||
|
||||
echo "🐳 TFM aInventory - Starting Deployment..."
|
||||
set -e
|
||||
|
||||
# 1. Check for configuration file
|
||||
if [ ! -f "inventory.env" ]; then
|
||||
echo "❌ ERROR: inventory.env not found!"
|
||||
echo "Please create it or use the template provided."
|
||||
exit 1
|
||||
# Load environment variables (from root inventory.env)
|
||||
if [ -f inventory.env ]; then
|
||||
export $(grep -v '^#' inventory.env | xargs)
|
||||
echo "✅ Loaded configuration from inventory.env"
|
||||
else
|
||||
echo "⚠️ inventory.env not found. Using default values."
|
||||
fi
|
||||
|
||||
# 2. Source the env file for the current shell (helps some docker versions)
|
||||
export $(grep -v '^#' inventory.env | xargs)
|
||||
# Parse arguments
|
||||
RESET_SSL=false
|
||||
RESET_ADMIN=false
|
||||
|
||||
# 3. Optional: Reset Caddy certificates if needed
|
||||
if [[ "$*" == *"--reset-ssl"* ]]; then
|
||||
echo "🧹 Resetting Caddy certificates..."
|
||||
for arg in "$@"; do
|
||||
case $arg in
|
||||
--reset-ssl)
|
||||
RESET_SSL=true
|
||||
shift
|
||||
;;
|
||||
--reset-admin)
|
||||
RESET_ADMIN=true
|
||||
shift
|
||||
;;
|
||||
--help)
|
||||
echo "Usage: ./deploy.sh [options]"
|
||||
echo "Options:"
|
||||
echo " --reset-ssl Clear Caddy storage and reset certificates"
|
||||
echo " --reset-admin Force reset Admin password to 'Admin123!'"
|
||||
echo " --help Show this help message"
|
||||
exit 0
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
if [ "$RESET_SSL" = true ]; then
|
||||
echo "🧹 Resetting SSL certificates..."
|
||||
docker compose down
|
||||
docker volume rm ainventory_caddy_data ainventory_caddy_config 2>/dev/null || true
|
||||
docker volume rm -f inventory_caddy_data 2>/dev/null || true
|
||||
echo "✅ SSL data cleared."
|
||||
fi
|
||||
|
||||
# 4. Run Docker Compose with explicit env-file flag
|
||||
echo "🚀 Building and starting containers..."
|
||||
echo "🚀 Starting TFM aInventory Services..."
|
||||
docker compose --env-file inventory.env up -d --build --remove-orphans
|
||||
|
||||
if [ "$RESET_ADMIN" = true ]; then
|
||||
echo "🔐 Resetting Admin credentials..."
|
||||
# Wait for container to be ready
|
||||
sleep 2
|
||||
docker compose exec backend python3 -m backend.scripts.reset_admin
|
||||
fi
|
||||
|
||||
echo ""
|
||||
echo "🔍 Verifying port mapping..."
|
||||
docker compose ps --format "table {{.Name}}\t{{.Status}}\t{{.Ports}}"
|
||||
@@ -34,9 +64,13 @@ echo "🚀 DIAGNOSTIC LOGS (Proxy SSL Handshake):"
|
||||
docker compose logs proxy --tail 20
|
||||
|
||||
echo ""
|
||||
echo "✅ Deployment requested."
|
||||
echo "✅ Deployment complete."
|
||||
echo " ------------------------------------------------------------"
|
||||
echo " 1. SECURE ACCESS (Try first): https://${SERVER_IP:-localhost}:${FRONTEND_SSL_PORT:-8919}"
|
||||
echo " 2. DIRECT ACCESS (Fallback): http://${SERVER_IP:-localhost}:${FRONTEND_PORT:-8917}"
|
||||
echo " DEFAULT CREDENTIALS:"
|
||||
echo " User: Admin"
|
||||
echo " Pass: Admin123!"
|
||||
echo " ------------------------------------------------------------"
|
||||
echo " 1. SECURE ACCESS: https://${SERVER_IP:-localhost}:${FRONTEND_SSL_PORT:-8919}"
|
||||
echo " 2. DIRECT ACCESS: http://${SERVER_IP:-localhost}:${FRONTEND_PORT:-8917}"
|
||||
echo " ------------------------------------------------------------"
|
||||
echo ""
|
||||
|
||||
Reference in New Issue
Block a user