chore: auto-generate secrets in nexusguard-install.sh, remove redundant install.sh

This commit is contained in:
datadunia
2026-05-31 06:14:28 +07:00
parent f4629401d8
commit 25df78c519
2 changed files with 25 additions and 22 deletions
+24 -21
View File
@@ -103,40 +103,43 @@ cp -r "$DASHBOARD_DIST"/* "$DASHBOARD_DIR/"
# Create config file (only if not exists)
if [ ! -f "$CONF_FILE" ]; then
info "Creating config file..."
info "Creating config file with auto-generated secrets..."
RANDOM_JWT=$(openssl rand -hex 32)
RANDOM_SALT=$(openssl rand -hex 32)
cat << EOF > "$CONF_FILE"
# NexusGuard Configuration
# This file is sourced by the server-core and nginx
# Generated by install.sh on $(date)
# Database
export DB_HOST=127.0.0.1
export DB_PORT=5432
export DB_USER=nexusguard
export DB_PASSWORD=nexusguard
export DB_NAME=nexusguard
DB_HOST=127.0.0.1
DB_PORT=5432
DB_USER=nexusguard
DB_PASSWORD=nexusguard
DB_NAME=nexusguard
# Redis
export REDIS_ADDR=127.0.0.1:6379
REDIS_ADDR=127.0.0.1:6379
# Security (CHANGE THESE!)
export JWT_SECRET=change-me-to-a-random-string
export SERVER_SALT=change-me-to-another-random-string
# Security (auto-generated)
JWT_SECRET=$RANDOM_JWT
SERVER_SALT=$RANDOM_SALT
# Network
export NFTABLES_TABLE=nexusguard
export IPAM_POOL=10.8.0.0/16
NFTABLES_TABLE=nexusguard
IPAM_POOL=10.8.0.0/16
# Server
export GIN_MODE=release
export PORT=$SERVER_PORT
GIN_MODE=release
PORT=$SERVER_PORT
# Dashboard
export API_BASE_URL=http://localhost:$SERVER_PORT/api/v1
export WEB_PORT=$WEB_PORT
CORS_ALLOWED_ORIGINS=http://localhost:$WEB_PORT
SHARE_LINK_TTL=24h
EOF
chmod 600 "$CONF_FILE"
warn "Config file created at $CONF_FILE"
warn "IMPORTANT: Edit $CONF_FILE and set JWT_SECRET and SERVER_SALT!"
info "Config file created at $CONF_FILE"
else
info "Config file already exists, skipping..."
fi
@@ -218,5 +221,5 @@ info "Access URL: http://localhost:$WEB_PORT"
info "Config file: $CONF_FILE"
info "Service status: systemctl status $SERVICE_NAME"
echo ""
warn "IMPORTANT: Edit $CONF_FILE to set secure JWT_SECRET and SERVER_SALT values!"
warn "Then restart the service: systemctl restart $SERVICE_NAME"
info "Secrets were auto-generated. Edit $CONF_FILE to customize if needed."
info "Restart after changes: systemctl restart $SERVICE_NAME"