Files
MIXBOX-ARCHIVE/apps/ngrok/config/mixbox.conf
2020-03-05 00:08:40 +08:00

81 lines
2.8 KiB
Plaintext
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
#------------------【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】--------------------