From 58ce4e5eb46889bcc5dfbae640fa5ff20d635a40 Mon Sep 17 00:00:00 2001 From: iiiiiii1 <25471406+iiiiiii1@users.noreply.github.com> Date: Sat, 12 May 2018 09:21:19 +0800 Subject: [PATCH] Update socat.sh --- socat.sh | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/socat.sh b/socat.sh index f2027f7..a102452 100644 --- a/socat.sh +++ b/socat.sh @@ -79,6 +79,13 @@ start_socat(){ chmod +x /etc/rc.d/rc.local else if [ -s /etc/rc.local ]; then + sed -i '/exit/d' /etc/rc.local + echo "nohup socat TCP4-LISTEN:${port1},reuseaddr,fork TCP4:${socatip}:${port2} >> /root/socat.log 2>&1 & + nohup socat -T 600 UDP4-LISTEN:${port1},reuseaddr,fork UDP4:${socatip}:${port2} >> /root/socat.log 2>&1 & + " >> /etc/rc.local + chmod +x /etc/rc.local + + else echo -e "${Green}检测到系统无/etc/rc.local自启,正在为其配置... ${Font} " echo "[Unit] Description=/etc/rc.local @@ -114,12 +121,6 @@ start_socat(){ chmod +x /etc/rc.local systemctl enable rc-local >/dev/null 2>&1 systemctl start rc-local >/dev/null 2>&1 - else - sed -i '/exit/d' /etc/rc.local - echo "nohup socat TCP4-LISTEN:${port1},reuseaddr,fork TCP4:${socatip}:${port2} >> /root/socat.log 2>&1 & - nohup socat -T 600 UDP4-LISTEN:${port1},reuseaddr,fork UDP4:${socatip}:${port2} >> /root/socat.log 2>&1 & - " >> /etc/rc.local - chmod +x /etc/rc.local fi fi get_ip