moxbox init

This commit is contained in:
monlor
2020-03-05 00:08:40 +08:00
commit 76dbe98978
856 changed files with 170708 additions and 0 deletions

View File

@@ -0,0 +1,63 @@
#------------------【SmartDNS】--------------------
smartdns() {
eval `mbdb export smartdns`
source /etc/mixbox/bin/base
uciset="mbdb set $appname.main"
echo "********* $service ***********"
echo "[${appinfo}]"
readsh "启动${appname}服务[1/0] " "enable" "1"
if [ "$enable" == '1' ]; then
# Scripts Here
readsh "请输入${appname}运行端口号" "port" "535"
echo "${appname}全部配置: "
[ -z "$(mbdb show ${appname}.info)" ] && echo "未添加配置!" || mbdb show ${appname}.info
read -p "是否要更改${appname}上游服务器配置?[1/0] " res
if [ "$res" == '1' ]; then
readsh "是否要使用工具箱内置的一些dns列表[百度、谷歌等]" "default_dns" "1"
read -p "添加${appname}上游服务器配置?[1/0] " res
if [ "$res" == '1' ]; then
while(true)
do
read -p "请输入${appname}的上游DNS服务器名称: " name
read -p "请输入${appname}的上游DNS服务器地址: " url
read -p "请输入${appname}的上游DNS服务器端口(默认53): " port
read -p "${appname}的上游服务器是否使用tcp查询方式[1/0] " tcp
if [ -z "$name" -o -z "$url" ]; then
echo "配置不能为空,未添加!"
else
[ -z "${port}" ] && port=53
if [ "$tcp" = '1' ]; then
mbdb set ${appname}.info.$name="server-tcp $url:${port}"
else
mbdb set ${appname}.info.$name="server $url:${port}"
fi
fi
echo "已添加配置[$name $url:${port}]"
read -p "继续添加配置?[1/0] " res
[ "$res" == '0' -o -z "$res" ] && break
done
fi
read -p "删除${appname}上游服务器配置?[1/0] " res
if [ "$res" == '1' ]; then
read -p "清空配置再添加?[1/0] " res
[ "$res" == '1' ] && mbdb clear ${appname}.info
echo "["$(mbdb keys ${appname}.info)"]"
while(true)
do
read -p "请输入要删除的配置名: " res
[ ! -z "$res" ] && mbdb del ${appname}.info.$res
read -p "继续删除配置?[1/0] " res
[ "$res" == '0' -o -z "$res" ] && break
done
fi
fi
${mbroot}/apps/${appname}/scripts/${appname}.sh restart
else
${mbroot}/apps/${appname}/scripts/${appname}.sh stop
fi
}
#------------------【SmartDNS】--------------------