Merge Lean's source

This commit is contained in:
CN_SZTL 2020-02-22 16:06:32 +08:00
commit 98c564de49
No known key found for this signature in database
GPG Key ID: 6850B6345C862176
10 changed files with 31 additions and 315 deletions

View File

@ -1,51 +0,0 @@
include $(TOPDIR)/rules.mk
PKG_NAME:=luci-app-dnspod
PKG_VERSION=1.0
PKG_RELEASE:=1
PKG_BUILD_DIR:=$(BUILD_DIR)/$(PKG_NAME)
include $(INCLUDE_DIR)/package.mk
include $(INCLUDE_DIR)/host-build.mk
define Package/luci-app-dnspod
SECTION:=luci
CATEGORY:=LuCI
SUBMENU:=3. Applications
TITLE:=Auto DNS for dnspod
PKGARCH:=all
DEPENDS:= +curl +libcurl
endef
define Package/luci-app-dnspod/description
auto get pub ip,dnspod ddns,must include curl with ssl
endef
define Build/Prepare
endef
define Build/Configure
endef
define Build/Compile
endef
define Package/luci-app-dnspod/install
$(INSTALL_DIR) $(1)/etc/config
$(INSTALL_DIR) $(1)/etc/init.d
$(INSTALL_DIR) $(1)/usr/lib/lua/luci/model/cbi
$(INSTALL_DIR) $(1)/usr/lib/lua/luci/controller
$(INSTALL_CONF) ./files/root/etc/config/dnspod $(1)/etc/config/dnspod
$(INSTALL_BIN) ./files/root/etc/init.d/dnspod $(1)/etc/init.d/dnspod
$(INSTALL_DATA) ./files/root/usr/lib/lua/luci/model/cbi/dnspod.lua $(1)/usr/lib/lua/luci/model/cbi/dnspod.lua
$(INSTALL_DATA) ./files/root/usr/lib/lua/luci/controller/dnspod.lua $(1)/usr/lib/lua/luci/controller/dnspod.lua
$(INSTALL_DIR) $(1)/usr/sbin
$(INSTALL_BIN) ./files/dnspod.sh $(1)/usr/sbin
endef
$(eval $(call BuildPackage,luci-app-dnspod))

View File

@ -1,169 +0,0 @@
#!/bin/bash
#written by Michael Qu
#greennyreborn@gmail.com
#dnspod api token
token=`uci get dnspod.base_arg.login_token`
#域名
domain=`uci get dnspod.base_arg.main_domain 2>/dev/null`
#需要更新的子域名,只允许一个
#由于*linux会被脚本解析为当前目录下的所有文件所以请填写\*
# sub_domain='\*'
sub_domain=`uci get dnspod.base_arg.sub_domain 2>/dev/null`
if [ $sub_domain = "\*" ]; then
sub_domain="*"
fi
#check for changed ip every 300 seconds
wait=300
wait_second=`uci get dnspod.base_arg.wait_second 2>/dev/null`
if [[ $wait_second =~ ^[1-9][0-9]*$ ]]; then
wait=$wait_second
fi
#外网ip获取命令
command=`uci get dnspod.base_arg.command_to_get_ip 2>/dev/null`
if [ -z "$command" ]; then
command='curl -s whatismyip.akamai.com'
fi
#检查curl是否安装
curl_status=`which curl 2>/dev/null`
[ -n "$curl_status" ] || { echo "curl is not installed";exit 3; }
os=$(uname -a | egrep -io 'openwrt' | tr [A-Z] [a-z])
API_url="https://dnsapi.cn"
LOG_FILE="/tmp/dnspod.log"
MAX_LOG_SIZE=`expr 1 * 1024 * 1024` # 默认最大限制1M
PROGRAM=$(basename $0)
format='json'
lang='en'
record_type='A'
common_options="login_token=$token&format=${format}&lang=${lang}"
is_svc=0
last_modified_ip=
getFileSize() {
local file=$1
wc -c $file | awk '{print $1}'
}
clearLog() {
local file_size=$(getFileSize $LOG_FILE)
if [ $file_size -gt $MAX_LOG_SIZE ]; then
echo "" > $LOG_FILE
printMsg "Log file [$LOG_FILE], size: [$file_size bytes]."
printMsg "Exceeds max log size [$MAX_LOG_SIZE]. Clear the log."
fi
}
printMsg() {
local time=$(date "+%Y-%m-%d %H:%M:%S")
local msg="$1"
if [ $is_svc -eq 1 ]; then
echo "$time: $msg" >> $LOG_FILE
# logger -t ${PROGRAM} "${msg}"
else
echo "$time: $msg"
fi
}
getIp() {
# curl -s http://checkip.dyndns.com | sed -n 's/.*: \([0-9]\{1,3\}\.[0-9]\{1,3\}\.[0-9]\{1,3\}\.[0-9]\{1,3\}\).*/\1/p'
eval $command
}
execAPI() {
local action="$1"
local extra_options="$2"
eval "curl -k -X POST \"${API_url}/${action}\" -d \"${common_options}&${extra_options}\""
}
getRecordList() {
local extra_options="domain=$domain"
echo $(execAPI "Record.List" "$extra_options")
exit
}
updateRecord() {
local ip=$1
local record_list=`getRecordList`
local old_ip=`jsonfilter -s "$record_list" -e "@.records[@.name='$sub_domain'].value"`
local id=`jsonfilter -s "$record_list" -e "@.records[@.name='$sub_domain'].id"`
printMsg "Change record: $sub_domain.$domain from $old_ip to $ip"
local extra_options="domain=$domain&record_id=$id&value=$ip&record_type=A&record_line_id=0&sub_domain=$sub_domain"
local response=$(execAPI "Record.Modify" "$extra_options")
local code=`jsonfilter -s "$response" -e "@.status.code"`
if [ "$code" == "1" ]; then
last_modified_ip=$ip
fi
local message=`jsonfilter -s "$response" -e "@.status.message"`
printMsg "response: $message"
}
checkip() {
local wan_ip=$1
printMsg "old ip: [$last_modified_ip], new ip: [$wan_ip]"
if [ "$wan_ip" != "$last_modified_ip" ]; then
return 8
else
return 3
fi
}
execSvc() {
local ip
#check that whether the network is ok
while [ 1 ];do
ip=$(getIp)
if [ -n "$ip" ]; then
printMsg "WAN IP: ${ip}"
break;
else
printMsg "Can't get wan ip"
sleep 30
fi
done
while [ 1 ];do
clearLog
ip=$(getIp)
checkip $ip
if [ $? -eq 8 ]; then
updateRecord $ip
#updateTunnelBroker
fi
sleep $wait
done
}
execUpdate() {
local ip=`getIp`
printMsg "WAN IP: ${ip}"
updateRecord $ip
}
case $1 in
--svc)
is_svc=1;
clearLog;
printMsg "Start in Service mode, check in every $wait seconds";
printMsg "domain: ${domain}, sub_domain: ${sub_domain}";
printMsg "Use command: [$command] to get wan ip";
execSvc;;
*)
is_svc=0;
printMsg "Start update record, domain: ${domain}, sub_domain: ${sub_domain}";
printMsg "Use command: [$command] to get wan ip";
execUpdate;;
esac

View File

@ -1,7 +0,0 @@
config base_arg "base_arg"
option main_domain ''
option sub_domain ''
option login_token ''
option wait_second ''
option command_to_get_ip 'curl -s whatismyip.akamai.com'

View File

@ -1,18 +0,0 @@
#!/bin/sh /etc/rc.common
START=80
start()
{
/usr/sbin/dnspod.sh --svc &
}
stop()
{
ps | grep dnspod.sh | grep -v 'grep' | awk '{print $1}' | xargs kill
}
run_reboot()
{
stop
start
}

View File

@ -1,5 +0,0 @@
module("luci.controller.dnspod", package.seeall)
function index()
entry({"admin", "network", "dnspod"}, cbi("dnspod"), _("动态DNSPOD"), 100)
end

View File

@ -1,32 +0,0 @@
--[[
LuCI - Lua Configuration Interface
Copyright 2010 Jo-Philipp Wich <xm@subsignal.org>
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
]]--
require("luci.sys")
m = Map("dnspod", translate("动态DNSPOD"), translate("配置动态DNSPOD"))
s = m:section(TypedSection, "base_arg", "")
s.addremove = false
s.anonymous = true
email = s:option(Value, "login_token", translate("DNSPOD Token"), "格式: ID,Token")
main = s:option(Value, "main_domain", translate("主域名"), "想要解析的主域名,例如:baidu.com")
sub = s:option(Value, "sub_domain", translate("子域名"), "想要解析的子域名,只允许填写一个。如果想解析*子域名,请填写 \\*")
wait = s:option(Value, "wait_second", translate("更新周期(s)"), "请填写数字默认为300s")
command = s:option(Value, "command_to_get_ip", translate("外网ip获取命令"), "默认为 curl -s whatismyip.akamai.com")
local apply = luci.http.formvalue("cbi.apply")
if apply then
io.popen("/etc/init.d/dnspod restart &")
end
return m

View File

@ -47,7 +47,7 @@ msgid "Server Address"
msgstr "服务器地址"
msgid "Server Port"
msgstr "服务器端口"
msgstr "端口"
msgid "Local Port"
msgstr "本地端口"

View File

@ -8,19 +8,18 @@
include $(TOPDIR)/rules.mk
PKG_NAME:=readline
PKG_VERSION:=7.0
PKG_VERSION:=8.0
PKG_RELEASE:=1
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
PKG_SOURCE_URL:=@GNU/readline
PKG_HASH:=750d437185286f40a369e1e4f4764eda932b9459b5ec9a731628393dd3d32334
PKG_HASH:=e339f51971478d369f8a053a330a190781acb9864cf4c541060f12078948e461
PKG_LICENSE:=GPL-3.0
PKG_LICENSE_FILES:=COPYING
PKG_CPE_ID:=cpe:/a:gnu:readline
PKG_BUILD_PARALLEL:=1
PKG_FIXUP:=autoreconf
PKG_INSTALL:=1
include $(INCLUDE_DIR)/package.mk
@ -30,45 +29,39 @@ define Package/libreadline
SECTION:=libs
CATEGORY:=Libraries
TITLE:=Command lines edition library
DEPENDS:=+libncursesw
URL:=http://cnswww.cns.cwru.edu/php/chet/readline/rltop.html
ABI_VERSION:=$(PKG_VERSION)
ABI_VERSION:=8
endef
define Package/libreadline/description
The Readline library provides a set of functions for use by applications
that allow users to edit command lines as they are typed in. Both Emacs
and vi editing modes are available. The Readline library includes
additional functions to maintain a list of previously-entered command
lines, to recall and perhaps reedit those lines, and perform csh-like
The Readline library provides a set of functions for use by applications
that allow users to edit command lines as they are typed in. Both Emacs
and vi editing modes are available. The Readline library includes
additional functions to maintain a list of previously-entered command
lines, to recall and perhaps reedit those lines, and perform csh-like
history expansion on previous commands.
endef
# prevent "autoreconf" from removing "aclocal.m4"
PKG_REMOVE_FILES:=
CONFIGURE_ARGS += \
--enable-shared \
--enable-static \
--with-curses \
CONFIGURE_ARGS += --with-curses --disable-install-examples
CONFIGURE_VARS += \
bash_cv_wcwidth_broken=no \
bash_cv_func_sigsetjmp=yes \
TARGET_CPPFLAGS:=-I. -I.. $(TARGET_CPPFLAGS)
TARGET_CFLAGS += $(FPIC)
define Build/InstallDev
$(INSTALL_DIR) $(1)/usr/include
$(CP) $(PKG_INSTALL_DIR)/usr/include/readline $(1)/usr/include/
$(INSTALL_DIR) $(1)/usr/lib
$(CP) $(PKG_INSTALL_DIR)/usr/lib/lib{history,readline}.{a,so,so.7,so.7.0} $(1)/usr/lib/
$(INSTALL_DIR) $(1)/usr/lib/pkgconfig
$(CP) $(PKG_INSTALL_DIR)/usr/lib/lib{history,readline}.{a,so*} $(1)/usr/lib/
$(CP) $(PKG_INSTALL_DIR)/usr/lib/pkgconfig/readline.pc $(1)/usr/lib/pkgconfig/
endef
define Package/libreadline/install
$(INSTALL_DIR) $(1)/usr/lib
$(CP) $(PKG_INSTALL_DIR)/usr/lib/lib{history,readline}.{so,so.7,so.7.0} $(1)/usr/lib/
$(CP) $(PKG_INSTALL_DIR)/usr/lib/lib{history,readline}.so.* $(1)/usr/lib/
endef
$(eval $(call HostBuild))

View File

@ -0,0 +1,16 @@
link readline directly to ncurses since it needs symbols from it
upstream readline does this on purpose (no direct linking), but
it doesn't make much sense in a Linux world
--- a/support/shobj-conf
+++ b/support/shobj-conf
@@ -42,7 +42,7 @@ SHOBJ_XLDFLAGS=
SHOBJ_LIBS=
SHLIB_XLDFLAGS=
-SHLIB_LIBS=
+SHLIB_LIBS=-lncurses
SHLIB_DOT='.'
SHLIB_LIBPREF='lib'

View File

@ -1,11 +0,0 @@
--- a/support/shlib-install
+++ b/support/shlib-install
@@ -73,7 +73,7 @@ fi
case "$host_os" in
hpux*|darwin*|macosx*|linux*|solaris2*)
if [ -z "$uninstall" ]; then
- chmod 555 ${INSTALLDIR}/${LIBNAME}
+ chmod +x ${INSTALLDIR}/${LIBNAME}
fi ;;
cygwin*|mingw*)
IMPLIBNAME=`echo ${LIBNAME} \