forked from lyarinet/Samba-Manager
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfix_network_access.sh
More file actions
executable file
·138 lines (115 loc) · 4.04 KB
/
Copy pathfix_network_access.sh
File metadata and controls
executable file
·138 lines (115 loc) · 4.04 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
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
#!/bin/bash
#
# Samba Manager Network Access Fix Script
#
# Check if script is running as root
if [[ $EUID -ne 0 ]]; then
echo "This script must be run as root. Please use sudo."
exit 1
fi
echo "=========================================================="
echo " Samba Manager Network Access Fix"
echo "=========================================================="
echo ""
# Get the server's IP address
SERVER_IP=$(hostname -I | awk '{print $1}')
echo "Server IP: $SERVER_IP"
# Update the systemd service file to explicitly bind to all interfaces
echo "Updating Samba Manager service configuration..."
cat > /etc/systemd/system/samba-manager.service << EOF
[Unit]
Description=Samba Manager Web Interface
After=network.target
[Service]
User=root
WorkingDirectory=/opt/samba-manager
ExecStart=/opt/samba-manager/venv/bin/python /opt/samba-manager/run.py --host 0.0.0.0 --port 5000
Restart=always
RestartSec=5
[Install]
WantedBy=multi-user.target
EOF
# Reload systemd and restart the service
echo "Reloading systemd and restarting Samba Manager service..."
systemctl daemon-reload
systemctl restart samba-manager.service
# Check if the service is running
if systemctl is-active --quiet samba-manager.service; then
echo "Samba Manager service is running."
else
echo "Warning: Samba Manager service is not running. Please check the logs."
fi
# Check if UFW is active
if command -v ufw &> /dev/null && ufw status | grep -q "Status: active"; then
echo "Configuring UFW firewall..."
# Allow Samba Manager web interface
ufw allow 5000/tcp
# Allow terminal service
ufw allow 8080/tcp
# Allow Samba
ufw allow Samba
echo "Firewall configured."
fi
# Check if firewalld is active
if command -v firewall-cmd &> /dev/null && firewall-cmd --state | grep -q "running"; then
echo "Configuring firewalld..."
# Allow Samba Manager web interface
firewall-cmd --permanent --add-port=5000/tcp
# Allow terminal service
firewall-cmd --permanent --add-port=8080/tcp
# Allow Samba
firewall-cmd --permanent --add-service=samba
firewall-cmd --reload
echo "Firewall configured."
fi
# Fix terminal service
echo "Updating terminal service configuration..."
cat > /opt/samba-manager/start_terminal_service.sh << EOF
#!/bin/bash
# Check if GoTTY is installed
if ! command -v gotty &> /dev/null; then
echo "GoTTY is not installed. Installing..."
# Check if Go is installed
if ! command -v go &> /dev/null; then
echo "Go is not installed. Installing..."
sudo apt update
sudo apt install -y golang-go
fi
# Install GoTTY
go install github.com/sorenisanerd/gotty@latest
# Add Go bin to PATH for this session
export PATH=\$PATH:\$(go env GOPATH)/bin
fi
# Remove existing config if it exists
if [ -e ~/.gotty ]; then
rm -rf ~/.gotty
fi
# Kill any existing GoTTY processes
pkill -f "gotty" 2>/dev/null || true
# Get the server's IP address
SERVER_IP=\$(hostname -I | awk '{print \$1}')
# Start GoTTY with bash in the background, explicitly binding to all interfaces
echo "Starting terminal service on port 8080..."
\$(go env GOPATH)/bin/gotty -w --address 0.0.0.0 --port 8080 bash &
echo "Terminal service started. You can access it at: http://\${SERVER_IP}:8080"
EOF
# Make the script executable
chmod +x /opt/samba-manager/start_terminal_service.sh
# Restart terminal service
echo "Restarting terminal service..."
pkill -f "gotty" 2>/dev/null || true
/opt/samba-manager/start_terminal_service.sh
echo ""
echo "=========================================================="
echo " Network Access Fix Complete"
echo "=========================================================="
echo ""
echo "Samba Manager web interface should now be accessible at:"
echo "http://$SERVER_IP:5000"
echo ""
echo "Terminal service should now be accessible at:"
echo "http://$SERVER_IP:8080"
echo ""
echo "If you still have connection issues, please check your network"
echo "configuration and ensure there are no other firewalls blocking access."
echo "=========================================================="