File size: 2,047 Bytes
31194ec
92721ae
 
 
31194ec
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
92721ae
31194ec
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
e0fca5d
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
#!/bin/bash
# Restore original xray binaries and data files from the backup location
# to the tmpfs-mounted bin directory.
cp -r /opt/xray-backup/. /usr/local/x-ui/bin/
echo "Architecture: $(uname -m)"

# --- Restore Configs from baked-in repo files ---
CONFIG_DIR_IN_REPO="/opt/app/x-ui-configs"
LIVE_XUI_DB_PATH="/tmp/x-ui.db"
LIVE_XRAY_CONFIG_PATH="/usr/local/x-ui/bin/config.json"

echo "Restoring configs from baked-in files..."
if [ -f "${CONFIG_DIR_IN_REPO}/config.json" ]; then
    cp -f "${CONFIG_DIR_IN_REPO}/config.json" "${LIVE_XRAY_CONFIG_PATH}"
    echo "Restored config.json"
fi
if [ -f "${CONFIG_DIR_IN_REPO}/x-ui.db" ]; then
    cp -f "${CONFIG_DIR_IN_REPO}/x-ui.db" "${LIVE_XUI_DB_PATH}"
    echo "Restored x-ui.db"
fi
# --- End Restore ---

# --- WARP SOCKS Proxy Setup ---
echo "Starting WARP SOCKS5 proxy via sing-box..."
nohup /opt/app/warp_proxy.sh > /tmp/warp.log 2>&1 &
echo "WARP SOCKS5 proxy started in background. Log at /tmp/warp.log"
# --- End WARP SOCKS Proxy Setup ---

# Set a writable directory for the x-ui database
export XUI_DB_FOLDER=/tmp

# Function to run chisel client in a loop
run_chisel() {
  while true; do
    echo "Starting chisel client..."
    # This is the line from the user's last instruction
    /usr/local/bin/chisel client -v --auth "cloud:2025" --keepalive 25s "https://vds1.iri1968.dpdns.org/chisel-ws" R:8080:127.0.0.1:2023 R:8081:127.0.0.1:20001
    echo "Chisel client exited. Restarting in 5 seconds..."
    sleep 5
  done
}

# Start chisel in the background
run_chisel &

# Wait a moment for the background process to start
sleep 2

# --- ADDED USER SETTINGS ---
echo "Configuring x-ui web base path..."
/usr/local/x-ui/x-ui setting -webBasePath /

echo "Resetting x-ui admin credentials..."
/usr/local/x-ui/x-ui setting -username prog10 -password 04091968

# This command is from a previous step, it is needed for the port
/usr/local/x-ui/x-ui setting -port 2023
# --- END ADDED SETTINGS ---

# Start x-ui in the foreground
echo "Starting x-ui panel..."
cd /usr/local/x-ui
exec ./x-ui