refactor: merge setup.sh into update.sh for seamless first-run

- update.sh now auto-generates .env from .env.example if missing
- Generates random JWT/SALT keys on first run
- Existing .env is never overwritten
- Deleted redundant setup.sh
- Updated all documentation references
This commit is contained in:
datadunia
2026-06-26 17:23:52 +07:00
parent fcb1de2cac
commit 4eea268ec5
8 changed files with 31 additions and 73 deletions
+21 -3
View File
@@ -32,10 +32,28 @@ while [[ $# -gt 0 ]]; do
esac
done
# 1. Pastikan file env ada
# 1. Auto-generate .env jika belum ada (seamless first-run)
if [ ! -f .env ]; then
echo "[-] ERROR: .env file not found. Please run ./setup.sh first to initialize configuration."
exit 1
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!"
echo "[+] Review .env file before continuing. Edit DB_PASSWORD, API_PORT, VITE_API_BASE_URL as needed."
else
echo "[-] ERROR: .env.example is missing. Cannot generate .env."
exit 1
fi
else
echo "[+] .env file already exists. Skipping environment generation."
fi
# 2. Update Code dari Git (Main & Submodules)