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:
@@ -28,8 +28,7 @@ NexusGuard SD-WAN Suite: Enterprise Zero-Trust SD-WAN with WireGuard tunneling,
|
||||
├── docker-compose.yml # Production orchestration
|
||||
├── docker-compose.dev.yml# Dev (air hot-reload)
|
||||
├── Makefile # up/down/dev/migrate/reset-db
|
||||
├── setup.sh # First-run: generate .env + random keys
|
||||
├── update.sh # Docker update: pull/build/migrate
|
||||
├── update.sh # Docker update: auto-generate .env + pull/build/migrate
|
||||
├── nexusguard-install.sh # Native install (systemd + nginx)
|
||||
├── nexusguard-uninstall.sh
|
||||
├── .env.example # DB/JWT/SALT/VITE config template
|
||||
|
||||
@@ -19,16 +19,17 @@ Clone this repository and start all services:
|
||||
```bash
|
||||
git clone https://git.datadunia.com/nexusguard/Nexus-Guard-Suite.git
|
||||
cd Nexus-Guard-Suite
|
||||
./setup.sh # Generate .env file automatically
|
||||
# Edit .env with your configuration
|
||||
bash update.sh # Pull, build, migrate, and start
|
||||
bash update.sh # Auto-generates .env + pulls, builds, migrates, starts
|
||||
```
|
||||
|
||||
The first run will automatically:
|
||||
- Pull the latest code and build the Docker containers (via `update.sh`).
|
||||
- Generate `.env` from `.env.example` with auto-generated JWT/SALT keys.
|
||||
- Pull the latest code and build the Docker containers.
|
||||
- Auto-generate the **Local Primary Node** WireGuard keys on the first boot.
|
||||
- Create the database schema via automated migration.
|
||||
|
||||
Edit `.env` afterward to customize `DB_PASSWORD`, `API_PORT`, `VITE_API_BASE_URL`.
|
||||
|
||||
**Update Options:**
|
||||
```bash
|
||||
bash update.sh # Smart update (only rebuild if changes detected)
|
||||
@@ -268,8 +269,7 @@ NexusGuard/
|
||||
├── bin/ # Built binaries (gitignored)
|
||||
├── docker-compose.yml # Docker orchestration
|
||||
├── docker-compose.dev.yml # Docker dev (hot-reload)
|
||||
├── update.sh # Docker update script
|
||||
├── setup.sh # Docker initial setup
|
||||
├── update.sh # Docker update + auto-setup script
|
||||
├── nexusguard-install.sh # Native install script
|
||||
├── nexusguard-uninstall.sh # Native uninstall script
|
||||
├── .env.example # Environment template
|
||||
|
||||
@@ -43,7 +43,6 @@ NexusGuard is a production-grade, zero-trust SD-WAN solution built with Go, Vue
|
||||
```bash
|
||||
git clone https://git.datadunia.com/nexusguard/Nexus-Guard-Suite.git
|
||||
cd Nexus-Guard-Suite
|
||||
./setup.sh
|
||||
bash update.sh
|
||||
```
|
||||
|
||||
|
||||
@@ -17,13 +17,7 @@ NexusGuard supports three deployment modes: Docker (recommended), native install
|
||||
git clone https://git.datadunia.com/nexusguard/Nexus-Guard-Suite.git
|
||||
cd Nexus-Guard-Suite
|
||||
|
||||
# Generate .env file
|
||||
./setup.sh
|
||||
|
||||
# Edit configuration
|
||||
nano .env
|
||||
|
||||
# Start all services
|
||||
# Start all services (auto-generates .env on first run)
|
||||
bash update.sh
|
||||
```
|
||||
|
||||
@@ -49,7 +43,7 @@ DB_NAME=nexusguard
|
||||
# Redis
|
||||
REDIS_ADDR=redis:6379
|
||||
|
||||
# Security (auto-generated by setup.sh)
|
||||
# Security (auto-generated by update.sh)
|
||||
JWT_SECRET=<hex-64-chars>
|
||||
SERVER_SALT=<hex-64-chars>
|
||||
|
||||
|
||||
@@ -246,7 +246,6 @@ Time-limited config sharing:
|
||||
```bash
|
||||
git clone https://git.datadunia.com/nexusguard/Nexus-Guard-Suite.git
|
||||
cd Nexus-Guard-Suite
|
||||
./setup.sh
|
||||
bash update.sh
|
||||
```
|
||||
|
||||
|
||||
@@ -172,7 +172,7 @@ Technical and precise. Avoid marketing buzzwords. Focus on:
|
||||
|
||||
**Content:**
|
||||
- Docker (Recommended):
|
||||
- Quick start (setup.sh + update.sh)
|
||||
- Quick start (bash update.sh)
|
||||
- Configuration (.env)
|
||||
- Makefile commands (up, down, logs, dev, migrate, reset-db)
|
||||
- Native Install:
|
||||
|
||||
@@ -1,51 +0,0 @@
|
||||
#!/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 Compose v2 is available
|
||||
if ! docker compose version &> /dev/null; then
|
||||
echo "[-] ERROR: docker compose (v2) is not available. Please install Docker and Docker Compose plugin."
|
||||
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 'bash update.sh' to download the "
|
||||
echo " latest code, build, and start the "
|
||||
echo " system. The script will also run "
|
||||
echo " database migrations automatically. "
|
||||
echo " "
|
||||
echo " 3. Create your Admin account: "
|
||||
echo " docker exec -it nexus-guard-suite-server-core-1 ./server-core -create-admin -user \"admin\" -pass \"PasswordKuat123!\""
|
||||
echo "========================================="
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user