Update entrypoint.sh
Browse files- entrypoint.sh +10 -11
entrypoint.sh
CHANGED
|
@@ -3,7 +3,7 @@ set -e
|
|
| 3 |
|
| 4 |
echo "Starting SSH/SOCKS5 NAT Gateway setup..."
|
| 5 |
|
| 6 |
-
#
|
| 7 |
PUBLIC_IP=$(curl -s ifconfig.me)
|
| 8 |
if [ -z "$PUBLIC_IP" ]; then
|
| 9 |
echo "Error: Could not fetch public IP. Exiting."
|
|
@@ -11,27 +11,26 @@ if [ -z "$PUBLIC_IP" ]; then
|
|
| 11 |
fi
|
| 12 |
echo "Detected public IP: $PUBLIC_IP"
|
| 13 |
|
| 14 |
-
#
|
| 15 |
if [ ! -f /etc/ssh/ssh_host_rsa_key ]; then
|
| 16 |
ssh-keygen -A
|
| 17 |
fi
|
| 18 |
|
| 19 |
-
|
| 20 |
-
/usr/sbin/sshd -D -e -f /etc/ssh/sshd_config > /var/log/sshd_debug.log 2>&1 &
|
| 21 |
|
| 22 |
echo "SSH server started."
|
| 23 |
|
| 24 |
-
# Start Dante
|
| 25 |
/usr/sbin/danted -D &
|
| 26 |
|
| 27 |
echo "Dante SOCKS5 server started."
|
| 28 |
|
| 29 |
-
#
|
| 30 |
-
iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE
|
| 31 |
-
iptables -A FORWARD -i eth0 -o eth0 -m state --state RELATED,ESTABLISHED -j ACCEPT
|
| 32 |
-
iptables -A FORWARD -i eth0 -o eth0 -j ACCEPT
|
| 33 |
|
| 34 |
-
echo "iptables NAT rules
|
| 35 |
|
| 36 |
-
# Keep
|
| 37 |
exec tail -f /dev/null
|
|
|
|
| 3 |
|
| 4 |
echo "Starting SSH/SOCKS5 NAT Gateway setup..."
|
| 5 |
|
| 6 |
+
# Get public IP
|
| 7 |
PUBLIC_IP=$(curl -s ifconfig.me)
|
| 8 |
if [ -z "$PUBLIC_IP" ]; then
|
| 9 |
echo "Error: Could not fetch public IP. Exiting."
|
|
|
|
| 11 |
fi
|
| 12 |
echo "Detected public IP: $PUBLIC_IP"
|
| 13 |
|
| 14 |
+
# Start SSHD
|
| 15 |
if [ ! -f /etc/ssh/ssh_host_rsa_key ]; then
|
| 16 |
ssh-keygen -A
|
| 17 |
fi
|
| 18 |
|
| 19 |
+
/usr/sbin/sshd -D -e -f /etc/ssh/sshd_config &
|
|
|
|
| 20 |
|
| 21 |
echo "SSH server started."
|
| 22 |
|
| 23 |
+
# Start Dante
|
| 24 |
/usr/sbin/danted -D &
|
| 25 |
|
| 26 |
echo "Dante SOCKS5 server started."
|
| 27 |
|
| 28 |
+
# NAT rules (requires privileged container)
|
| 29 |
+
/sbin/iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE || echo "⚠️ iptables failed. Privileged mode required."
|
| 30 |
+
/sbin/iptables -A FORWARD -i eth0 -o eth0 -m state --state RELATED,ESTABLISHED -j ACCEPT || true
|
| 31 |
+
/sbin/iptables -A FORWARD -i eth0 -o eth0 -j ACCEPT || true
|
| 32 |
|
| 33 |
+
echo "iptables NAT rules attempted."
|
| 34 |
|
| 35 |
+
# Keep container alive
|
| 36 |
exec tail -f /dev/null
|