-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathAutoNode.sh
More file actions
63 lines (47 loc) · 1.81 KB
/
Copy pathAutoNode.sh
File metadata and controls
63 lines (47 loc) · 1.81 KB
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
while true; do
echo "Do you want to add a new node to Marzban? (Y/N)"
read choice
if [ "$choice" == "Y" ] || [ "$choice" == "y" ]; then
echo "Enter the IP address of the node server:"
read ip_address
echo "Enter the certificate of the node in Marzban panel. Press Ctrl+D twice when finished:"
cert_content=$(</dev/stdin)
echo "Enter the service port number:"
read service_port
echo "Enter the XRAY API port number:"
read xray_port
new_content="services:
marzban-node:
# build: .
image: gozargah/marzban-node:latest
restart: always
network_mode: host
environment:
SERVICE_PORT: $service_port
XRAY_API_PORT: $xray_port
SSL_CLIENT_CERT_FILE: "/var/lib/marzban-node/ssl_client_cert.pem"
SERVICE_PROTOCOL: rest
volumes:
- /var/lib/marzban-node:/var/lib/marzban-node
"
ssh -o StrictHostKeyChecking=no -o "UserKnownHostsFile=/dev/null" root@$ip_address "
apt-get update; apt-get upgrade -y; apt-get install curl socat git -y; apt --fix-broken install
curl -fsSL https://get.docker.com | sh
cd /root/
git clone https://github.com/Gozargah/Marzban-node
sudo mkdir -p /var/lib/marzban-node
sudo touch /var/lib/marzban-node/ssl_client_cert.pem
echo \"$cert_content\" | sudo tee /var/lib/marzban-node/ssl_client_cert.pem > /dev/null
echo \"$new_content\" | sudo tee /root/Marzban-node/docker-compose.yml > /dev/null
cd /root/Marzban-node
docker compose down --remove-orphans; docker compose up -d
"
echo "Node addition process completed."
elif [ "$choice" == "N" ] || [ "$choice" == "n" ]; then
echo "No new node will be added. Exiting..."
break
else
echo "Invalid choice. Please enter Y/y or N/n."
fi
done