diff --git a/udptools.sh b/udptools.sh index c1c4f8f..54af60b 100644 --- a/udptools.sh +++ b/udptools.sh @@ -43,7 +43,7 @@ fi buildServer() { -#写入配置 +#写入Udp2Raw配置 cat > /usr/local/udptools/conf/udp2raw-s${MPORT}.conf < /usr/local/udptools/conf/udp2raw-s${MPORT}.conf < /usr/local/udptools/udp2raw-s${MPORT}.sh <> $LOG_FILE + echo $IPTALBES >> $LOG_FILE if [ ! -n "$IPTALBES" ]; then echo "Adding iptables rules." #添加iptables规则 @@ -102,9 +104,11 @@ status(){ fi } start(){ - checkSet #启动进程 - sudo -u nobody -b $BIN_FILE --conf-file $CONFIG_FILE >> $LOG_FILE 2>&1 + sudo -u root -b $BIN_FILE --keep-rule --conf-file $CONFIG_FILE >> $LOG_FILE 2>&1 + #checkSet + #sudo -u nobody -b $BIN_FILE --conf-file $CONFIG_FILE >> $LOG_FILE 2>&1 + #Centos8无法nobody运行 status } stop(){ @@ -147,6 +151,79 @@ EOF chmod +x /usr/local/udptools/udp2raw-s${MPORT}.sh +#写入UdpSpeeder脚本 +cat > /usr/local/udptools/udpspeeder-s${MPORT}.sh <> /usr/local/udptools/udp2raw-s${MPORT}.sh <<"EOF" +status(){ + PID=`ps aux|grep -e "$CONFIG"|grep -v sudo|grep -v grep | awk '{print $2}'` + if [ ! -n "$PID" ]; then + rm -f $PID_FILE + echo "$PROG已停止." + else + echo $PID > $PID_FILE + echo "$PROG已启动. PID: $PID" + fi +} +start(){ + #启动进程 + sudo -u nobody -b $BIN_FILE $CONFIG >> $LOG_FILE 2>&1 + status +} +stop(){ + #结束进程 + PID=`cat $PID_FILE` + kill $PID >/dev/null 2>&1 + status +} +showLog(){ + cat $LOG_FILE | tail -n 50 +} +case "$1" in +start) + echo "Starting $PROG..." + start + ;; +stop) + echo "Stopping $PROG..." + stop + ;; +restart) + echo "Stopping $PROG..." + stop + sleep 2 + echo "Starting $PROG..." + start + ;; +status) + status + ;; +log) + showLog + ;; +*) + echo "Usage: $PROG {start|stop|restart|status|log}" + ;; +esac +exit 0 +EOF + #判断服务模式 if pgrep systemd-journal > /dev/null; then SYSTEMCTL=1 @@ -161,7 +238,9 @@ chmod +x /usr/local/udptools/udp2raw-s${MPORT}.sh buildClient() { - echo "-c +#写入Udp2Raw配置 +cat > /usr/local/udptools/conf/udp2raw-c${MPORT}.conf < /usr/local/udptools/conf/udp2raw-c${MPORT}.conf +# 修复粘包 +EOF #判断服务模式 if pgrep systemd-journal > /dev/null; then @@ -265,4 +345,4 @@ case $RUNMODE in buildServer ;; -esac \ No newline at end of file +esac diff --git a/uninstall.sh b/uninstall.sh index 72f6991..a028d25 100644 --- a/uninstall.sh +++ b/uninstall.sh @@ -15,10 +15,12 @@ echo "删除相关服务" #判断服务模式 if pgrep systemd-journal > /dev/null; then if ls /usr/lib/systemd/system/ | grep -q -e "udp2raw*.service"; then - find /usr/lib/systemd/system/ -name "udp2raw*.service" | xargs -0 rm + find /etc/systemd/system/ -name "udp2raw*" | xargs -0 rm + find /usr/lib/systemd/system/ -name "udp2raw*" | xargs -0 rm fi if ls /usr/lib/systemd/system/ | grep -q -e "udpspeeder*.service"; then - find /usr/lib/systemd/system/ -name "udpspeeder*.service" | xargs -0 rm + find /etc/systemd/system/ -name "udpspeeder*" | xargs -0 rm + find /usr/lib/systemd/system/ -name "udpspeeder*" | xargs -0 rm fi else if ls /etc/init.d/ | grep -q -e "udp2raw*"; then