2018-12-31

This commit is contained in:
monlor
2018-12-31 23:47:47 +08:00
commit 3ae56f5e6e
1091 changed files with 173538 additions and 0 deletions

Binary file not shown.

Binary file not shown.

View File

@@ -0,0 +1,81 @@
#------------------【Ngrok】--------------------
ngrokAdd() {
read -p "请输入${appname}名称:" name
[ -z "$name" ] && return
read -p "请输入${appname}类型(1.http 2.tcp)" type
read -p "请输入${appname}本地ip(回车默认192.168.31.1)" local_ip
read -p "请输入${appname}本地端口:" local_port
[ "$type" == '2' ] && read -p "请输入${appname}远程访问端口:" remote_port
[ "$type" == '1' ] && read -p "请输入${appname}域名(自动识别子域名或自定义域名)" domain
if [ ! -z $name ]; then
[ -z $local_ip ] && local_ip=192.168.31.1
if [ "$type" == '1' ]; then
type=http
elif [ "$type" == '2' ]; then
type=tcp
else
type="输入有误"
fi
read -p "确定要添加配置:$name,$type,$local_ip,$local_port,$remote_port,$domain[1/0] " res
if [ "$res" == '1' ]; then
sed -i "/^$name,/d" $NGLIST
echo "$name,$type,$local_ip,$local_port,$remote_port,$domain" >> $NGLIST
fi
fi
read -p "添加完成,再添加一个?[1/0] " res
if checkread $res; then
[ "$res" == '1' ] && ngrokAdd
fi
}
ngrokDel() {
ngroklist=$(cat $NGLIST | cut -d, -f1)
echo "${appname}穿透配置[`echo $ngroklist`]"
read -p "请输入要删除的配置名:" res
[ ! -z "$res" ] && sed -i "/^$res,/d" $NGLIST
read -p "删除完成,继续删除?[1/0] " res
if checkread $res; then
[ "$res" == '1' ] && ngrokDel
fi
}
ngrok() {
eval `mbdb export ngrok`
source /etc/mixbox/bin/base
NGLIST=${mbroot}/apps/ngrok/config/ngroklist
[ ! -f $NGLIST ] && touch $NGLIST
echo "********* $service ***********"
echo "[${appinfo}]"
readsh "启动${appname}服务[1/0] " "enable" "1"
if [ "$enable" == '1' ]; then
ser_host=$(mbdb get ${appname}.main.ser_host)
ser_port=$(mbdb get ${appname}.main.ser_port)
ser_token=$(mbdb get ${appname}.main.ser_token)
[ -z $ser_host ] && ser_host="空"
[ -z $ser_port ] && ser_port="空"
[ -z $ser_token ] && ser_token="空"
read -p "修改${appname}服务器($ser_host, $ser_port, $ser_token)[1/0] " res
if [ "$res" == '1' ]; then
read -p "请输入${appname}服务器:" res
mbdb set $appname.main.ser_host="$res"
read -p "请输入${appname}服务器端口:" res
mbdb set $appname.main.ser_port="$res"
read -p "请输入${appname}服务器秘钥:" res
mbdb set $appname.main.ser_token="$res"
fi
ngroklist=$(cat $NGLIST | cut -d, -f1)
[ -z "$ngroklist" ] && ngroklist="空"
echo "${appname}穿透配置[`echo $ngroklist`]"
read -p "添加${appname}穿透配置?[1/0] " res
[ "$res" == '1' ] && ngrokAdd
read -p "删除${appname}穿透配置?[1/0] " res
[ "$res" == '1' ] && ngrokDel
fi
if [ "$enable" == '1' ]; then
${mbroot}/apps/${appname}/scripts/${appname}.sh restart
else
${mbroot}/apps/${appname}/scripts/${appname}.sh stop
fi
}
#------------------【Ngrok】--------------------

View File

@@ -0,0 +1,8 @@
service="Ngrok"
appname="ngrok"
needver="0.0.1"
supports="linux_arm,linux_mips"
backupfiles="config/ngroklist"
appinfo="轻量级的内网穿透工具"
newinfo=""
version="0.0.2"

View File

@@ -0,0 +1 @@
1.0.5

View File

@@ -0,0 +1,83 @@
#!/bin/sh
source /etc/mixbox/bin/base
eval `mbdb export ngrok`
set_config() {
local cmdstr=""
ser_token=$(mbdb get ${appname}.main.ser_token)
while read line
do
[ `echo ${line} | grep -c "^#"` -ne 0 ] && continue
type=`echo ${line} | awk -F ',' '{print$2}'`
lhost=`echo ${line} | awk -F ',' '{print$3}'`
lport=`echo ${line} | awk -F ',' '{print$4}'`
rport=`echo ${line} | awk -F ',' '{print$5}'`
domain=`echo ${line} | awk -F ',' '{print$6}'`
if [ "$type" == "tcp" ]; then
cmdstr="$cmdstr -AddTun[Type:$type,Lhost:$lhost,Lport:$lport,Rport:$rport]"
else
if [ `echo $domain | grep "\." | wc -l` -ne 0 ]; then
cmdstr="$cmdstr -AddTun[Type:$type,Lhost:$lhost,Lport:$lport,Hostname:$domain]"
else
cmdstr="$cmdstr -AddTun[Type:$type,Lhost:$lhost,Lport:$lport,Sdname:$domain]"
fi
fi
done < ${mbroot}/apps/${appname}/config/ngroklist
[ -z "$cmdstr" ] || cmdstr="${mbroot}/apps/${appname}/bin/${appname} -SER[Shost:$ser_host,Sport:$ser_port,Password:$ser_token]$cmdstr"
echo $cmdstr
}
start () {
result=$(ps | grep ${mbroot}/apps/${appname}/bin/${appname} | grep -v grep | wc -l)
if [ "$result" != '0' ];then
logsh "$service" "${appname}已经在运行!"
exit 1
fi
logsh "$service" "正在启动${appname}服务... "
[ -z "$ser_host" -o -z "$ser_port" ] && logsh "$service" "${appname}未配置" && exit
runstr=`set_config`
# open_port
# write_firewall_start
daemon $runstr
if [ $? -ne 0 ]; then
logsh "$service" "启动${appname}服务失败!"
else
logsh "$service" "启动${appname}服务完成!"
fi
}
stop () {
logsh "$service" "正在停止${appname}服务... "
killall -9 ${appname} &> /dev/null
#
}
status() {
result=$(pssh | grep ${mbroot}/apps/${appname}/bin/${appname} | grep -v grep | wc -l)
if [ "$result" == '0' ]; then
status="未运行|0"
else
status="运行服务器: $ser_host:$ser_port|1"
fi
mbdb set $appname.main.status="$status"
}
case "$1" in
start) start ;;
stop) stop ;;
restart) stop; start ;;
reload) stop; start ;;
status) status ;;
esac