Files
Nexus-Guard-Suite/setup.sh
T

48 lines
1.6 KiB
Bash
Executable File

#!/bin/bash
set -e
echo "========================================="
echo " NexusGuard SD-WAN: INITIAL SETUP "
echo "========================================="
# 1. Environment File Generation
if [ ! -f .env ]; then
echo "[!] .env file not found."
if [ -f .env.example ]; then
echo "[+] Auto-generating .env from .env.example..."
cp .env.example .env
# Generate secure random hex keys
RANDOM_JWT=$(openssl rand -hex 32)
RANDOM_SALT=$(openssl rand -hex 32)
sed -i "s/GantiDenganKunciRahasiaJWTUntukDashboard256Bit/$RANDOM_JWT/g" .env
sed -i "s/GantiDenganKunciGaramUntukWireGuard256Bit/$RANDOM_SALT/g" .env
echo "[+] Secure cryptographic keys have been auto-generated!"
else
echo "[-] ERROR: .env.example is missing. Cannot generate .env."
exit 1
fi
else
echo "[+] .env file already exists. Skipping environment generation."
fi
# Make sure Docker is available
if ! command -v docker-compose &> /dev/null; then
echo "[-] ERROR: docker-compose is not installed. Please install Docker and Docker-Compose first."
exit 1
fi
echo ""
echo "========================================="
echo " Setup complete! Next Steps: "
echo " 1. Open and review the '.env' file. "
echo " Make sure to change DB_PASSWORD, "
echo " API_PORT, and VITE_API_BASE_URL. "
echo " "
echo " 2. Run './update.sh' to download the "
echo " latest code, build, and start the "
echo " system. "
echo "========================================="