优化安装逻辑

This commit is contained in:
CN-JS-HuiBai
2026-04-14 23:26:34 +08:00
parent 638dad7a0a
commit 2a099e7adf
2 changed files with 18 additions and 3 deletions

4
.env.example Normal file
View File

@@ -0,0 +1,4 @@
# sing-box Xboard Node Configuration
PANEL_URL=https://your-panel.com
PANEL_TOKEN=your_node_key
NODE_ID=1

View File

@@ -113,10 +113,21 @@ build_sing_box() {
install_go install_go
build_sing_box build_sing_box
# Load .env if exists
if [[ -f ".env" ]]; then
echo -e "${YELLOW}Loading configuration from .env...${NC}"
source .env
fi
# Interactive Prompts # Interactive Prompts
read -p "Enter Panel URL (e.g., https://yourbase.com): " PANEL_URL read -p "Enter Panel URL [${PANEL_URL}]: " INPUT_URL
read -p "Enter Node ID: " NODE_ID PANEL_URL=${INPUT_URL:-$PANEL_URL}
read -p "Enter Panel Token (Node Key): " PANEL_TOKEN
read -p "Enter Node ID [${NODE_ID}]: " INPUT_ID
NODE_ID=${INPUT_ID:-$NODE_ID}
read -p "Enter Panel Token (Node Key) [${PANEL_TOKEN}]: " INPUT_TOKEN
PANEL_TOKEN=${INPUT_TOKEN:-$PANEL_TOKEN}
if [[ -z "$PANEL_URL" || -z "$NODE_ID" || -z "$PANEL_TOKEN" ]]; then if [[ -z "$PANEL_URL" || -z "$NODE_ID" || -z "$PANEL_TOKEN" ]]; then
echo -e "${RED}All fields are required!${NC}" echo -e "${RED}All fields are required!${NC}"