-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetup-node.sh
More file actions
88 lines (71 loc) · 2.19 KB
/
Copy pathsetup-node.sh
File metadata and controls
88 lines (71 loc) · 2.19 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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
#!/bin/bash
# Setup script for ordinary proxy nodes.
set -e
MODE=${1:-default}
PYTHON_BIN="${PYTHON_BIN:-python3}"
if [ "$MODE" = "cn2" ]; then
echo "🚀 Setting up nginx proxy node with CN2 mode..."
else
echo "🚀 Setting up nginx proxy node..."
fi
echo ""
# Install system dependencies
bash script/install_prerequisites.sh
echo ""
if ! command -v "$PYTHON_BIN" >/dev/null 2>&1; then
if command -v python >/dev/null 2>&1; then
PYTHON_BIN="python"
else
echo "✗ Python is required to read the public network registry" >&2
exit 1
fi
fi
# Install Shadowsocks service
bash script/install_shadowsocks.sh
echo ""
STREAMS_TMP_DIR="$(mktemp -d)"
trap 'rm -rf "$STREAMS_TMP_DIR"' EXIT
# Generate nginx stream configs from the public network registry
"$PYTHON_BIN" script/registry.py write-nginx-streams --output-dir "$STREAMS_TMP_DIR"
echo ""
# Configure nginx (all streams)
bash script/copy_nginx_config.sh "$STREAMS_TMP_DIR"
echo ""
# Configure nginx service limits required by high worker_connections values
bash script/configure_nginx_limits.sh
echo ""
if [ "$MODE" = "cn2" ]; then
# Apply CN2 local traffic limits before (re)starting nginx
bash script/configure_cn2_forward_delay.sh enable
echo ""
else
# Disable CN2 local traffic limits under the default mode
bash script/configure_cn2_forward_delay.sh disable
echo ""
fi
# Start/restart nginx service
bash script/validate_and_restart_nginx.sh
echo ""
# Setup log management
bash script/setup_logrotate.sh
echo ""
# Install and configure Netdata as a Child node
bash script/install_netdata_child.sh
echo ""
# Install registry refresh timer after Netdata is available for refresh hooks
bash script/install_registry_refresh_timer.sh
echo ""
# Display network information
bash script/print_public_ip.sh
echo ""
echo "🎉 Node setup completed successfully!"
echo ""
echo "📝 Next steps:"
echo " • Monitor logs: bash monitor_logs.sh"
echo " • Check nginx: systemctl status nginx"
echo " • Check Netdata: systemctl status netdata"
echo " • Check Shadowsocks: sudo docker ps --filter name=otaku-shadowsocks"
if [ "$MODE" = "cn2" ]; then
echo " • View CN2 local limits: tc qdisc show && nginx -T"
fi
echo " • View nginx config: nginx -T"