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.yml # Production orchestration
|
||||||
├── docker-compose.dev.yml# Dev (air hot-reload)
|
├── docker-compose.dev.yml# Dev (air hot-reload)
|
||||||
├── Makefile # up/down/dev/migrate/reset-db
|
├── Makefile # up/down/dev/migrate/reset-db
|
||||||
├── setup.sh # First-run: generate .env + random keys
|
├── update.sh # Docker update: auto-generate .env + pull/build/migrate
|
||||||
├── update.sh # Docker update: pull/build/migrate
|
|
||||||
├── nexusguard-install.sh # Native install (systemd + nginx)
|
├── nexusguard-install.sh # Native install (systemd + nginx)
|
||||||
├── nexusguard-uninstall.sh
|
├── nexusguard-uninstall.sh
|
||||||
├── .env.example # DB/JWT/SALT/VITE config template
|
├── .env.example # DB/JWT/SALT/VITE config template
|
||||||
|
|||||||
@@ -19,16 +19,17 @@ Clone this repository and start all services:
|
|||||||
```bash
|
```bash
|
||||||
git clone https://git.datadunia.com/nexusguard/Nexus-Guard-Suite.git
|
git clone https://git.datadunia.com/nexusguard/Nexus-Guard-Suite.git
|
||||||
cd Nexus-Guard-Suite
|
cd Nexus-Guard-Suite
|
||||||
./setup.sh # Generate .env file automatically
|
bash update.sh # Auto-generates .env + pulls, builds, migrates, starts
|
||||||
# Edit .env with your configuration
|
|
||||||
bash update.sh # Pull, build, migrate, and start
|
|
||||||
```
|
```
|
||||||
|
|
||||||
The first run will automatically:
|
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.
|
- Auto-generate the **Local Primary Node** WireGuard keys on the first boot.
|
||||||
- Create the database schema via automated migration.
|
- Create the database schema via automated migration.
|
||||||
|
|
||||||
|
Edit `.env` afterward to customize `DB_PASSWORD`, `API_PORT`, `VITE_API_BASE_URL`.
|
||||||
|
|
||||||
**Update Options:**
|
**Update Options:**
|
||||||
```bash
|
```bash
|
||||||
bash update.sh # Smart update (only rebuild if changes detected)
|
bash update.sh # Smart update (only rebuild if changes detected)
|
||||||
@@ -268,8 +269,7 @@ NexusGuard/
|
|||||||
├── bin/ # Built binaries (gitignored)
|
├── bin/ # Built binaries (gitignored)
|
||||||
├── docker-compose.yml # Docker orchestration
|
├── docker-compose.yml # Docker orchestration
|
||||||
├── docker-compose.dev.yml # Docker dev (hot-reload)
|
├── docker-compose.dev.yml # Docker dev (hot-reload)
|
||||||
├── update.sh # Docker update script
|
├── update.sh # Docker update + auto-setup script
|
||||||
├── setup.sh # Docker initial setup
|
|
||||||
├── nexusguard-install.sh # Native install script
|
├── nexusguard-install.sh # Native install script
|
||||||
├── nexusguard-uninstall.sh # Native uninstall script
|
├── nexusguard-uninstall.sh # Native uninstall script
|
||||||
├── .env.example # Environment template
|
├── .env.example # Environment template
|
||||||
|
|||||||
@@ -43,7 +43,6 @@ NexusGuard is a production-grade, zero-trust SD-WAN solution built with Go, Vue
|
|||||||
```bash
|
```bash
|
||||||
git clone https://git.datadunia.com/nexusguard/Nexus-Guard-Suite.git
|
git clone https://git.datadunia.com/nexusguard/Nexus-Guard-Suite.git
|
||||||
cd Nexus-Guard-Suite
|
cd Nexus-Guard-Suite
|
||||||
./setup.sh
|
|
||||||
bash update.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
|
git clone https://git.datadunia.com/nexusguard/Nexus-Guard-Suite.git
|
||||||
cd Nexus-Guard-Suite
|
cd Nexus-Guard-Suite
|
||||||
|
|
||||||
# Generate .env file
|
# Start all services (auto-generates .env on first run)
|
||||||
./setup.sh
|
|
||||||
|
|
||||||
# Edit configuration
|
|
||||||
nano .env
|
|
||||||
|
|
||||||
# Start all services
|
|
||||||
bash update.sh
|
bash update.sh
|
||||||
```
|
```
|
||||||
|
|
||||||
@@ -49,7 +43,7 @@ DB_NAME=nexusguard
|
|||||||
# Redis
|
# Redis
|
||||||
REDIS_ADDR=redis:6379
|
REDIS_ADDR=redis:6379
|
||||||
|
|
||||||
# Security (auto-generated by setup.sh)
|
# Security (auto-generated by update.sh)
|
||||||
JWT_SECRET=<hex-64-chars>
|
JWT_SECRET=<hex-64-chars>
|
||||||
SERVER_SALT=<hex-64-chars>
|
SERVER_SALT=<hex-64-chars>
|
||||||
|
|
||||||
|
|||||||
@@ -246,7 +246,6 @@ Time-limited config sharing:
|
|||||||
```bash
|
```bash
|
||||||
git clone https://git.datadunia.com/nexusguard/Nexus-Guard-Suite.git
|
git clone https://git.datadunia.com/nexusguard/Nexus-Guard-Suite.git
|
||||||
cd Nexus-Guard-Suite
|
cd Nexus-Guard-Suite
|
||||||
./setup.sh
|
|
||||||
bash update.sh
|
bash update.sh
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|||||||
@@ -172,7 +172,7 @@ Technical and precise. Avoid marketing buzzwords. Focus on:
|
|||||||
|
|
||||||
**Content:**
|
**Content:**
|
||||||
- Docker (Recommended):
|
- Docker (Recommended):
|
||||||
- Quick start (setup.sh + update.sh)
|
- Quick start (bash update.sh)
|
||||||
- Configuration (.env)
|
- Configuration (.env)
|
||||||
- Makefile commands (up, down, logs, dev, migrate, reset-db)
|
- Makefile commands (up, down, logs, dev, migrate, reset-db)
|
||||||
- Native Install:
|
- 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,11 +32,29 @@ while [[ $# -gt 0 ]]; do
|
|||||||
esac
|
esac
|
||||||
done
|
done
|
||||||
|
|
||||||
# 1. Pastikan file env ada
|
# 1. Auto-generate .env jika belum ada (seamless first-run)
|
||||||
if [ ! -f .env ]; then
|
if [ ! -f .env ]; then
|
||||||
echo "[-] ERROR: .env file not found. Please run ./setup.sh first to initialize configuration."
|
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
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
else
|
||||||
|
echo "[+] .env file already exists. Skipping environment generation."
|
||||||
|
fi
|
||||||
|
|
||||||
# 2. Update Code dari Git (Main & Submodules)
|
# 2. Update Code dari Git (Main & Submodules)
|
||||||
echo "[+] Pulling latest source code from repository..."
|
echo "[+] Pulling latest source code from repository..."
|
||||||
|
|||||||
Reference in New Issue
Block a user