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