From ad80ad0c0872ac5313a1f4752994d77da4862c61 Mon Sep 17 00:00:00 2001 From: datadunia Date: Sat, 16 May 2026 02:52:08 +0700 Subject: [PATCH] feat(devops): auto generate secure cryptographic keys in setup --- setup.sh | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/setup.sh b/setup.sh index 2af1541..2dcf692 100755 --- a/setup.sh +++ b/setup.sh @@ -11,7 +11,18 @@ if [ ! -f .env ]; then if [ -f .env.example ]; then echo "[+] Auto-generating .env from .env.example..." cp .env.example .env - echo "[!] IMPORTANT: Please review the .env file and change the default passwords!" + + # Generate secure random hex keys for JWT and Server Salt + # Memastikan sistem aman tanpa campur tangan manual + RANDOM_JWT=$(openssl rand -hex 32) + RANDOM_SALT=$(openssl rand -hex 32) + + # Replace the placeholders in the newly created .env file + sed -i "s/GantiDenganKunciRahasiaJWTUntukDashboard256Bit/$RANDOM_JWT/g" .env + sed -i "s/GantiDenganKunciGaramUntukWireGuard256Bit/$RANDOM_SALT/g" .env + + echo "[+] Secure random cryptographic keys have been auto-generated!" + echo "[!] IMPORTANT: Please review the .env file to change the default database passwords!" else echo "[-] ERROR: .env.example is missing. Cannot generate .env." exit 1 @@ -26,10 +37,17 @@ if ! command -v docker-compose &> /dev/null; then exit 1 fi +echo "[+] Sourcing environment variables to prepare builds..." +export $(grep -v '^#' .env | xargs) + +echo "[+] Rebuilding containers if necessary..." +docker-compose build --build-arg VITE_API_BASE_URL=$VITE_API_BASE_URL + echo "[+] Bringing up Docker containers..." docker-compose up -d echo "======================================" echo " NexusGuard is successfully running! " -echo " API Port : 8080" +echo " Web Dashboard : http://localhost" +echo " API Port : ${API_PORT:-8080}" echo "======================================"