parent
2e7b67057d
commit
16be536c5e
|
|
@ -0,0 +1,79 @@
|
|||
#!/bin/bash
|
||||
#
|
||||
# speeder startup script for the UDPspeeder Client
|
||||
#
|
||||
#
|
||||
# chkconfig: 345 80 20
|
||||
# description: start the udp2raw deamon
|
||||
#
|
||||
# Source function library
|
||||
. /etc/rc.d/init.d/functions
|
||||
|
||||
prog=UDPspeeder-Client
|
||||
#程序目录
|
||||
HOME_DIR=/usr/local/udptools
|
||||
#程序文件名
|
||||
BIN_NAME=speederv2_x86
|
||||
#日志文件
|
||||
LOG_FILE=$HOME_DIR/speeder-client.log
|
||||
#配置参数
|
||||
CONFIG='-c -l0.0.0.0:5394 -r 127.0.0.1:5395 -f20:20 --mode 0'
|
||||
#-l0.0.0.0:5394监听5394给原始服务用
|
||||
#-r 127.0.0.1:5395连接udp2raw端口
|
||||
|
||||
start(){
|
||||
#启动进程
|
||||
sudo -u nobody -b $HOME_DIR/$BIN_NAME $CONFIG >> $LOG_FILE 2>&1
|
||||
}
|
||||
|
||||
stop(){
|
||||
#结束进程
|
||||
PID=`ps aux|grep $BIN_NAME|grep -e "$CONFIG"|grep -v root|grep -v grep | awk '{print $2}'`
|
||||
kill $PID >/dev/null 2>&1
|
||||
}
|
||||
|
||||
status(){
|
||||
PID=`ps aux|grep $BIN_NAME|grep -e "$CONFIG"|grep -v root|grep -v grep | awk '{print $2}'`
|
||||
if [ ! -n "$PID" ]; then
|
||||
echo "$prog is stopped."
|
||||
else
|
||||
echo "$prog is running. pid $PID"
|
||||
fi
|
||||
}
|
||||
|
||||
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
|
||||
|
|
@ -0,0 +1,79 @@
|
|||
#!/bin/bash
|
||||
#
|
||||
# speeder startup script for the UDPspeeder Server
|
||||
#
|
||||
#
|
||||
# chkconfig: 345 80 20
|
||||
# description: start the udp2raw deamon
|
||||
#
|
||||
# Source function library
|
||||
. /etc/rc.d/init.d/functions
|
||||
|
||||
prog=UDPspeeder-Server
|
||||
#程序目录
|
||||
HOME_DIR=/usr/local/udptools
|
||||
#程序文件名
|
||||
BIN_NAME=speederv2_x86
|
||||
#日志文件
|
||||
LOG_FILE=$HOME_DIR/speeder-server.log
|
||||
#配置参数
|
||||
CONFIG='-s -l127.0.0.1:5395 -r 127.0.0.1:5394 -f20:20 --mode 0'
|
||||
#-l127.0.0.1:5395监听端口给udp2raw用
|
||||
#-r 127.0.0.1:5394连接原始服务端口
|
||||
|
||||
start(){
|
||||
#启动进程
|
||||
sudo -u nobody -b $HOME_DIR/$BIN_NAME $CONFIG >> $LOG_FILE 2>&1
|
||||
}
|
||||
|
||||
stop(){
|
||||
#结束进程
|
||||
PID=`ps aux|grep $BIN_NAME|grep -e "$CONFIG"|grep -v root|grep -v grep | awk '{print $2}'`
|
||||
kill $PID >/dev/null 2>&1
|
||||
}
|
||||
|
||||
status(){
|
||||
PID=`ps aux|grep $BIN_NAME|grep -e "$CONFIG"|grep -v root|grep -v grep | awk '{print $2}'`
|
||||
if [ ! -n "$PID" ]; then
|
||||
echo "$prog is stopped."
|
||||
else
|
||||
echo "$prog is running. pid $PID"
|
||||
fi
|
||||
}
|
||||
|
||||
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
|
||||
|
|
@ -0,0 +1,95 @@
|
|||
#!/bin/bash
|
||||
#
|
||||
# udp2raw startup script for the Udp2Raw Client
|
||||
#
|
||||
#
|
||||
# chkconfig: 345 80 20
|
||||
# description: start the udp2raw deamon
|
||||
#
|
||||
# Source function library
|
||||
. /etc/rc.d/init.d/functions
|
||||
|
||||
prog=Udp2Raw-Client
|
||||
#程序目录
|
||||
HOME_DIR=/usr/local/udptools
|
||||
#程序文件名
|
||||
BIN_NAME=udp2raw_x86
|
||||
#配置文件
|
||||
CONFIG_FILE=$HOME_DIR/udp2raw-client.conf
|
||||
#日志文件
|
||||
LOG_FILE=$HOME_DIR/udp2raw-client.log
|
||||
|
||||
#Function
|
||||
checkSet(){
|
||||
#获取远程端口和地址
|
||||
SERVER_PORT=`cat $CONFIG_FILE | grep '\-r ' | awk -F ":" '{print $2}'`
|
||||
SERVER_ADDRESS=`cat $CONFIG_FILE | grep '\-r ' | awk -F ":" '{print $1}' | awk '{print $2}'`
|
||||
#检查iptables规则
|
||||
IPTALBES=`iptables -nvL | grep DROP | grep tcp | grep $SERVER_PORT | grep $SERVER_ADDRESS`
|
||||
if [ ! -n "$IPTALBES" ]; then
|
||||
echo "Adding iptables rules."
|
||||
#添加iptables规则
|
||||
RULES=`$HOME_DIR/$BIN_NAME --conf-file $CONFIG_FILE -g | grep iptables |grep -v rule`
|
||||
$RULES
|
||||
fi
|
||||
#赋权
|
||||
setcap cap_net_raw+ep $HOME_DIR/$BIN_NAME
|
||||
}
|
||||
|
||||
start(){
|
||||
checkSet
|
||||
#启动进程
|
||||
sudo -u nobody -b $HOME_DIR/$BIN_NAME --conf-file $CONFIG_FILE >> $LOG_FILE 2>&1
|
||||
}
|
||||
|
||||
stop(){
|
||||
#结束进程
|
||||
PID=`ps aux|grep $BIN_NAME|grep $CONFIG_FILE|grep -v root|grep -v grep | awk '{print $2}'`
|
||||
kill $PID >/dev/null 2>&1
|
||||
}
|
||||
|
||||
status(){
|
||||
PID=`ps aux|grep $BIN_NAME|grep $CONFIG_FILE|grep -v root|grep -v grep | awk '{print $2}'`
|
||||
if [ ! -n "$PID" ]; then
|
||||
echo "$prog is stopped."
|
||||
else
|
||||
echo "$prog is running. pid $PID"
|
||||
fi
|
||||
}
|
||||
|
||||
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
|
||||
|
|
@ -0,0 +1,94 @@
|
|||
#!/bin/bash
|
||||
#
|
||||
# udp2raw startup script for the Udp2Raw Server
|
||||
#
|
||||
#
|
||||
# chkconfig: 345 80 20
|
||||
# description: start the udp2raw deamon
|
||||
#
|
||||
# Source function library
|
||||
. /etc/rc.d/init.d/functions
|
||||
|
||||
prog=Udp2Raw-Server
|
||||
#程序目录
|
||||
HOME_DIR=/usr/local/udptools
|
||||
#程序文件名
|
||||
BIN_NAME=udp2raw_x86
|
||||
#配置文件
|
||||
CONFIG_FILE=$HOME_DIR/udp2raw-server.conf
|
||||
#日志文件
|
||||
LOG_FILE=$HOME_DIR/udp2raw-server.log
|
||||
|
||||
#Function
|
||||
checkSet(){
|
||||
#获取监听端口
|
||||
SERVER_PORT=`cat $CONFIG_FILE | grep '\-l ' | awk -F ":" '{print $2}'`
|
||||
#检查iptables规则
|
||||
IPTALBES=`iptables -nvL | grep DROP | grep tcp | grep $SERVER_PORT`
|
||||
if [ ! -n "$IPTALBES" ]; then
|
||||
echo "Adding iptables rules."
|
||||
#添加iptables规则
|
||||
RULES=`$HOME_DIR/$BIN_NAME --conf-file $CONFIG_FILE -g | grep iptables |grep -v rule`
|
||||
$RULES
|
||||
fi
|
||||
#赋权
|
||||
setcap cap_net_raw+ep $HOME_DIR/$BIN_NAME
|
||||
}
|
||||
|
||||
start(){
|
||||
checkSet
|
||||
#启动进程
|
||||
sudo -u nobody -b $HOME_DIR/$BIN_NAME --conf-file $CONFIG_FILE >> $LOG_FILE 2>&1
|
||||
}
|
||||
|
||||
stop(){
|
||||
#结束进程
|
||||
PID=`ps aux|grep $BIN_NAME|grep $CONFIG_FILE|grep -v root|grep -v grep | awk '{print $2}'`
|
||||
kill $PID >/dev/null 2>&1
|
||||
}
|
||||
|
||||
status(){
|
||||
PID=`ps aux|grep $BIN_NAME|grep $CONFIG_FILE|grep -v root|grep -v grep | awk '{print $2}'`
|
||||
if [ ! -n "$PID" ]; then
|
||||
echo "$prog is stopped."
|
||||
else
|
||||
echo "$prog is running. pid $PID"
|
||||
fi
|
||||
}
|
||||
|
||||
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
|
||||
|
|
@ -5,8 +5,8 @@ Before= # 表示需要在某些服务启动之前启动,After
|
|||
|
||||
[Service] # 核心区域
|
||||
Type=forking # 表示后台运行模式。
|
||||
User=nobody # 设置服务运行的用户
|
||||
Group=nobody # 设置服务运行的用户组
|
||||
User=root # 设置服务运行的用户
|
||||
Group=root # 设置服务运行的用户组
|
||||
KillMode=control-group # 定义systemd如何停止服务
|
||||
PIDFile=/usr/local/udptools/pid/udp2raw-%i.pid # 存放PID的绝对路径
|
||||
Restart=no # 定义服务进程退出后,systemd的重启方式,默认是不重启
|
||||
|
|
|
|||
|
|
@ -5,8 +5,8 @@ Before= # 表示需要在某些服务启动之前启动,After
|
|||
|
||||
[Service] # 核心区域
|
||||
Type=forking # 表示后台运行模式。
|
||||
User=nobody # 设置服务运行的用户
|
||||
Group=nobody # 设置服务运行的用户组
|
||||
User=root # 设置服务运行的用户
|
||||
Group=root # 设置服务运行的用户组
|
||||
KillMode=control-group # 定义systemd如何停止服务
|
||||
PIDFile=/usr/local/udptools/pid/udpspeeder-%i.pid # 存放PID的绝对路径
|
||||
Restart=no # 定义服务进程退出后,systemd的重启方式,默认是不重启
|
||||
|
|
|
|||
26
udptools.sh
26
udptools.sh
|
|
@ -26,15 +26,28 @@ if [ "$IPTABLES" == '' ]; then
|
|||
fi
|
||||
fi
|
||||
|
||||
#判断服务模式
|
||||
if pgrep systemd-journal; then
|
||||
buildServer()
|
||||
{
|
||||
#判断服务模式
|
||||
if pgrep systemd-journal; then
|
||||
SYSTEMCTL=1
|
||||
else
|
||||
SYSTEMCTL=0
|
||||
fi
|
||||
fi
|
||||
echo $PASSWD
|
||||
echo $RPORT
|
||||
echo $MPORT
|
||||
echo $LPORT
|
||||
}
|
||||
|
||||
testFun()
|
||||
buildClient()
|
||||
{
|
||||
#判断服务模式
|
||||
if pgrep systemd-journal; then
|
||||
SYSTEMCTL=1
|
||||
else
|
||||
SYSTEMCTL=0
|
||||
fi
|
||||
echo $PASSWD
|
||||
echo $REMOTEIP
|
||||
echo $RPORT
|
||||
|
|
@ -42,6 +55,7 @@ testFun()
|
|||
echo $LPORT
|
||||
}
|
||||
|
||||
|
||||
echo
|
||||
echo "Which mode to run this?"
|
||||
echo "你想运行在什么模式?"
|
||||
|
|
@ -80,7 +94,7 @@ case $RUNMODE in
|
|||
fi
|
||||
echo""
|
||||
done
|
||||
testFun
|
||||
buildClient
|
||||
;;
|
||||
2)
|
||||
read -p "Udp2Raw Password(Udp2Raw密码): " PASSWD
|
||||
|
|
@ -115,6 +129,6 @@ case $RUNMODE in
|
|||
fi
|
||||
echo""
|
||||
done
|
||||
testFun
|
||||
buildServer
|
||||
;;
|
||||
esac
|
||||
Loading…
Reference in New Issue