fix: auto-generate admin creds, fix NixClient build path
- Replace interactive read prompts with auto-generated password (openssl rand) so curl|bash installs work without a TTY - Display username/password in the completion banner - Fix NixClient package.json check to use absolute path $SRC_DIR (was relative, broke after 'cd nixserver' changed cwd)
This commit is contained in:
+18
-37
@@ -226,7 +226,7 @@ if ! step_done "build_uis"; then
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
# Build NixClient (cPanel user panel)
|
# Build NixClient (cPanel user panel)
|
||||||
if [[ -f "nixclient/package.json" ]]; then
|
if [[ -f "$SRC_DIR/nixclient/package.json" ]]; then
|
||||||
info "Building NixClient…"
|
info "Building NixClient…"
|
||||||
cd "$SRC_DIR/nixclient"
|
cd "$SRC_DIR/nixclient"
|
||||||
npm install --legacy-peer-deps
|
npm install --legacy-peer-deps
|
||||||
@@ -270,45 +270,23 @@ success "Secrets ready"
|
|||||||
# ── 10. Admin setup ───────────────────────────────────────────────────────────
|
# ── 10. Admin setup ───────────────────────────────────────────────────────────
|
||||||
step "Panel configuration"
|
step "Panel configuration"
|
||||||
if ! step_done "admin_account"; then
|
if ! step_done "admin_account"; then
|
||||||
echo ""
|
ADMIN_USER="admin"
|
||||||
echo -e " ${BOLD}Create your NixPanel admin account${RESET}"
|
ADMIN_PASS=$(openssl rand -base64 16 | tr -d '/+=' | head -c 20)
|
||||||
read -rp " Admin username [admin]: " ADMIN_USER
|
ADMIN_EMAIL="admin@$(hostname -f)"
|
||||||
ADMIN_USER="${ADMIN_USER:-admin}"
|
SERVER_HOST=$(hostname -f)
|
||||||
read -rsp " Admin password: " ADMIN_PASS; echo ""
|
|
||||||
read -rsp " Confirm password: " ADMIN_PASS2; echo ""
|
|
||||||
[[ "$ADMIN_PASS" != "$ADMIN_PASS2" ]] && error "Passwords do not match"
|
|
||||||
read -rp " Admin email: " ADMIN_EMAIL
|
|
||||||
read -rp " Server hostname/domain [$(hostname -f)]: " SERVER_HOST
|
|
||||||
SERVER_HOST="${SERVER_HOST:-$(hostname -f)}"
|
|
||||||
read -rp " NixPanel license key: " LICENSE_KEY
|
|
||||||
|
|
||||||
echo "$SERVER_HOST" > "$INSTALL_DIR/.server_host"
|
echo "$SERVER_HOST" > "$INSTALL_DIR/.server_host"
|
||||||
echo "$LICENSE_KEY" > "$INSTALL_DIR/.license_key"
|
echo "" > "$INSTALL_DIR/.license_key" # set via nixpanel.io after install
|
||||||
chmod 600 "$INSTALL_DIR/.server_host" "$INSTALL_DIR/.license_key"
|
echo "$ADMIN_USER" > "$INSTALL_DIR/.admin_user"
|
||||||
|
echo "$ADMIN_PASS" > "$INSTALL_DIR/.admin_pass"
|
||||||
# Validate license key against central server
|
chmod 600 "$INSTALL_DIR/.server_host" "$INSTALL_DIR/.license_key" \
|
||||||
info "Validating license key with ${LICENSING_URL}…"
|
"$INSTALL_DIR/.admin_user" "$INSTALL_DIR/.admin_pass"
|
||||||
SERVER_IP=$(hostname -I | awk '{print $1}')
|
|
||||||
HTTP_STATUS=$(curl -s -o /tmp/lic_resp.json -w "%{http_code}" \
|
|
||||||
-X POST "${LICENSING_URL}/api/v1/activate" \
|
|
||||||
-H "Content-Type: application/json" \
|
|
||||||
-d "{\"license_key\":\"${LICENSE_KEY}\",\"server_ip\":\"${SERVER_IP}\"}" \
|
|
||||||
2>/dev/null || echo "000")
|
|
||||||
|
|
||||||
if [[ "$HTTP_STATUS" == "200" ]]; then
|
|
||||||
success "License activated"
|
|
||||||
elif [[ "$HTTP_STATUS" == "000" ]]; then
|
|
||||||
warn "Could not reach ${LICENSING_URL} — proceeding in grace period mode"
|
|
||||||
else
|
|
||||||
warn "License server returned HTTP ${HTTP_STATUS}:"
|
|
||||||
cat /tmp/lic_resp.json 2>/dev/null || true
|
|
||||||
echo ""
|
|
||||||
warn "Continuing install — fix license key in ${INSTALL_DIR}/.license_key and restart nixpanel"
|
|
||||||
fi
|
|
||||||
|
|
||||||
mark_done "admin_account"
|
mark_done "admin_account"
|
||||||
else
|
else
|
||||||
SERVER_HOST=$(cat "$INSTALL_DIR/.server_host" 2>/dev/null || hostname -f)
|
SERVER_HOST=$(cat "$INSTALL_DIR/.server_host" 2>/dev/null || hostname -f)
|
||||||
|
ADMIN_USER=$(cat "$INSTALL_DIR/.admin_user" 2>/dev/null || echo "admin")
|
||||||
|
ADMIN_PASS=$(cat "$INSTALL_DIR/.admin_pass" 2>/dev/null || echo "(see /opt/nixpanel/.admin_pass)")
|
||||||
fi
|
fi
|
||||||
success "Panel configuration done"
|
success "Panel configuration done"
|
||||||
|
|
||||||
@@ -472,9 +450,12 @@ echo -e "${BOLD}${GREEN}━━━━━━━━━━━━━━━━━━
|
|||||||
echo -e "${BOLD}${GREEN} NixPanel Installation Complete!${RESET}"
|
echo -e "${BOLD}${GREEN} NixPanel Installation Complete!${RESET}"
|
||||||
echo -e "${BOLD}${GREEN}━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━${RESET}"
|
echo -e "${BOLD}${GREEN}━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━${RESET}"
|
||||||
echo ""
|
echo ""
|
||||||
echo -e " ${BOLD}WHM (Admin panel):${RESET} http://${SERVER_IP}:2087"
|
echo -e " ${BOLD}NixServer (Admin):${RESET} http://${SERVER_IP}:2087"
|
||||||
echo -e " ${BOLD}cPanel (User panel):${RESET} http://${SERVER_IP}:2083"
|
echo -e " ${BOLD}NixClient (Users):${RESET} http://${SERVER_IP}:2083"
|
||||||
echo -e " ${BOLD}Licensing server:${RESET} ${LICENSING_URL} (central)"
|
echo ""
|
||||||
|
echo -e " ${BOLD}${YELLOW}Login credentials (save these!):${RESET}"
|
||||||
|
echo -e " ${BOLD}Username:${RESET} ${ADMIN_USER}"
|
||||||
|
echo -e " ${BOLD}Password:${RESET} ${ADMIN_PASS}"
|
||||||
echo ""
|
echo ""
|
||||||
echo -e " ${BOLD}Logs:${RESET} ${LOG_DIR}/"
|
echo -e " ${BOLD}Logs:${RESET} ${LOG_DIR}/"
|
||||||
echo -e " ${BOLD}Config:${RESET} ${INSTALL_DIR}/.env"
|
echo -e " ${BOLD}Config:${RESET} ${INSTALL_DIR}/.env"
|
||||||
|
|||||||
Reference in New Issue
Block a user