diff --git a/cfddns/backup.sh b/cfddns/backup.sh new file mode 100755 index 0000000..dd1d4ab --- /dev/null +++ b/cfddns/backup.sh @@ -0,0 +1,25 @@ +#! /bin/sh + +# you can do something here +# this shell scripts will run at the end of build.py scripts + + + +mkdir -p history +if [ ! -f ./history/version ];then + touch ./history/version +fi + +version_old=`cat history/version | awk '{print $1}' | sort -rn |sed -n 1p` +version_new=`cat config.json.js |grep "version"|cut -d"\"" -f 4` +md5_old=`cat history/version | sort -nk1 | awk '{print $1}' |sed -n 1p` +md5_new=` md5sum aliddns.tar.gz | awk '{print $1}'` + +if [ -f ./aliddns.tar.gz ];then + if [ "$version_old" != "$version_new" ];then + mkdir ./history/$version_new/ + cp ./aliddns.tar.gz ./history/$version_new/ + echo $version_new $md5_new >> ./history/version + fi +fi + diff --git a/cfddns/build.sh b/cfddns/build.sh new file mode 100755 index 0000000..b02d77a --- /dev/null +++ b/cfddns/build.sh @@ -0,0 +1,32 @@ +#!/bin/sh + + +MODULE=cfddns +VERSION=1.2 +TITLE=Cloudflare DDNS +DESCRIPTION=Cloudflare解析自动更新IP +HOME_URL=Module_cfddns.asp + +# Check and include base +DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" +if [ "$MODULE" == "" ]; then + echo "module not found" + exit 1 +fi + +if [ -f "$DIR/$MODULE/$MODULE/install.sh" ]; then + echo "install script not found" + exit 2 +fi + +# now include build_base.sh +. $DIR/../softcenter/build_base.sh + +# change to module directory +cd $DIR + +# do something here + +do_build_result + +sh backup.sh $MODULE diff --git a/cfddns/cfddns.tar.gz b/cfddns/cfddns.tar.gz new file mode 100644 index 0000000..08938d6 Binary files /dev/null and b/cfddns/cfddns.tar.gz differ diff --git a/cfddns/cfddns/install.sh b/cfddns/cfddns/install.sh new file mode 100755 index 0000000..b68ea02 --- /dev/null +++ b/cfddns/cfddns/install.sh @@ -0,0 +1,14 @@ +#!/bin/sh + +cp -r /tmp/cfddns/res/* /jffs/softcenter/res +cp -r /tmp/cfddns/scripts/* /jffs/softcenter/scripts +cp -r /tmp/cfddns/webs/* /jffs/softcenter/webs + +chmod 644 /jffs/softcenter/webs/Module_cfddns.asp +chmod 666 /jffs/softcenter/res/icon-cfddns.png +chmod 755 /jffs/softcenter/scripts/cfddns_* + +# add icon into softerware center +dbus set softcenter_module_cfddns_install=1 +dbus set softcenter_module_cfddns_version=1.0.0 +dbus set softcenter_module_cfddns_description="Cloudflare DDNS" diff --git a/cfddns/cfddns/res/icon-cfddns.png b/cfddns/cfddns/res/icon-cfddns.png new file mode 100755 index 0000000..637fd19 Binary files /dev/null and b/cfddns/cfddns/res/icon-cfddns.png differ diff --git a/cfddns/cfddns/scripts/cfddns_config.sh b/cfddns/cfddns/scripts/cfddns_config.sh new file mode 100755 index 0000000..d7ecc21 --- /dev/null +++ b/cfddns/cfddns/scripts/cfddns_config.sh @@ -0,0 +1,7 @@ +#!/bin/sh + +if [ "`dbus get cfddns_enable`" == "1" ]; then + dbus delay cfddns_timer `dbus get cfddns_interval` /jffs/softcenter/scripts/cfddns_update.sh +else + dbus remove __delay__cfddns_timer +fi diff --git a/cfddns/cfddns/scripts/cfddns_update.sh b/cfddns/cfddns/scripts/cfddns_update.sh new file mode 100755 index 0000000..5536e06 --- /dev/null +++ b/cfddns/cfddns/scripts/cfddns_update.sh @@ -0,0 +1,64 @@ +#!/bin/sh + +eval `dbus export cfddns_` + +if [ "$cfddns_enable" != "1" ]; then + echo "not enable" + exit +fi + +now=`date '+%Y-%m-%d %H:%M:%S'` +ip=`$cfddns_curl 2>&1` || die "$ip" +record_response=`curl -kLsX GET "https://api.cloudflare.com/client/v4/zones/$cfddns_zone/dns_records?type=A&name=$cfddns_domain&order=type&direction=desc&match=all" -H "X-Auth-Email: $cfddns_email" -H "X-Auth-Key: $cfddns_key" -H "Content-type: application/json"` +cfddns_id=`echo "$record_response" | awk -F"","" '{print $1}' | sed 's/{.*://g'` + +[ "$cfddns_curl" = "" ] && cfddns_curl="curl -s whatismyip.akamai.com" +[ "$cfddns_ttl" = "" ] && cfddns_ttl="600" + +die () { + echo $1 + dbus ram cfddns_last_act="$now: failed($1)" +} + +urlencode() { + # urlencode + out="" + while read -n1 c; do + case $c in + [a-zA-Z0-9._-]) out="$out$c" ;; + *) out="$out`printf '%%%02X' "'$c"`" ;; + esac + done + echo -n $out +} + +enc() { + echo -n "$1" | urlencode +} + +update_record() { + curl -kLsX PUT "https://api.cloudflare.com/client/v4/zones/$cfddns_zone/dns_records/$cfddns_id" \ + -H "X-Auth-Email: $cfddns_email" \ + -H "X-Auth-Key: $cfddns_key" \ + -H "Content-Type: application/json" \ + --data '{"type":"A","name":"$cfddns_domain","content":"$ip","ttl":"$cfddns_ttl","proxied":false}' +} + +if [ "$?" -eq "0" ]; then + current_ip=`echo "$record_response" | awk -F"","" '{print $4}' |grep -oE '([0-9]{1,3}\.?){4}'` + + if [ "$ip" = "$current_ip" ]; then + echo "skipping" + dbus set cfddns_last_act="$now: 跳过更新,路由器IP:($ip),A记录IP:($current_ip)" + exit 0 + else + echo "changing" + update_record + new_ip=`echo "$record_response" | awk -F"","" '{print $4}' |grep -oE '([0-9]{1,3}\.?){4}'` + if [ "$new_ip" = "$ip" ]; then + dbus set cfddns_last_act="$now: 更新成功,路由器IP:($ip),A记录IP:($new_ip)" + else + dbus set cfddns_last_act="$now: 更新失败!请检查设置" + fi + fi +fi diff --git a/cfddns/cfddns/scripts/uninstall_cfddns.sh b/cfddns/cfddns/scripts/uninstall_cfddns.sh new file mode 100755 index 0000000..c963afd --- /dev/null +++ b/cfddns/cfddns/scripts/uninstall_cfddns.sh @@ -0,0 +1,12 @@ +#!/bin/sh + +rm /jffs/softcenter/res/icon-cfddns.png > /dev/null 2>&1 +rm /jffs/softcenter/webs/Module_cfddns.asp > /dev/null 2>&1 +rm /jffs/softcenter/scripts/cfddns_config.sh > /dev/null 2>&1 +rm /jffs/softcenter/scripts/cfddns_update.sh > /dev/null 2>&1 +rm /jffs/softcenter/scripts/uninstall_cfddns.sh > /dev/null 2>&1 + +dbus remove __delay__cfddns_timer +dbus remove softcenter_module_cfddns_install +dbus remove softcenter_module_cfddns_version +dbus remove softcenter_module_cfddns_description diff --git a/cfddns/cfddns/webs/Module_cfddns.asp b/cfddns/cfddns/webs/Module_cfddns.asp new file mode 100755 index 0000000..0b9535b --- /dev/null +++ b/cfddns/cfddns/webs/Module_cfddns.asp @@ -0,0 +1,212 @@ + + + + + + + + + + Cloudflare DDNS + + + + + + + + + +
+ + + + + + + + + +
  + + + + + + + + + + + +
+
+ + + + + + +
+
 
+
Cloudflare DDNS - 设置
+
+
+
Cloudflare DDNS是基于 Cloudflare API 实现的个人 DDNS 工具。  点击查看插件详情
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Cloudflare DDNS - 设置面板
+
+ +
+
+
上次运行 <% dbus_get_def("cfddns_last_act", "--"); %>
API KEY " class="input_ss_table">
User Email" class="input_ss_table">
ZONE" class="input_ss_table">
检查周期" class="input_ss_table">s
主域名" class="input_ss_table">
获得IP命令(?)
TTL(?)">s (1~86400)
+
+ +
+
+ +
+
+ 论坛技术支持: + www.koolshare.cn
+ Github项目: + github.com/koolshare
+ Shell by: kyrios , Web by: kyrios +
+
+
+
+ +
+ + + + diff --git a/cfddns/config.json.js b/cfddns/config.json.js new file mode 100644 index 0000000..6971adc --- /dev/null +++ b/cfddns/config.json.js @@ -0,0 +1,8 @@ +{ +"version":"1.2", +"md5":"a5412ac92b26967a619c8c458f839733", +"home_url":"Module_cfddns.asp", +"title":"", +"description":"Cloudflare解析自动更新IP", +"build_date":"2019-01-13_22:44:33" +} diff --git a/cfddns/history/version b/cfddns/history/version new file mode 100644 index 0000000..e69de29 diff --git a/cfddns/version b/cfddns/version new file mode 100644 index 0000000..53fbefe --- /dev/null +++ b/cfddns/version @@ -0,0 +1,2 @@ +1.2 +a5412ac92b26967a619c8c458f839733 diff --git a/softcenter/app.json.js b/softcenter/app.json.js index e822e33..8306f7a 100644 --- a/softcenter/app.json.js +++ b/softcenter/app.json.js @@ -10,6 +10,16 @@ "title": "网络测速", "version": "0.2.3" }, + { + "build_date": "2019-01-13_22:44:33", + "description": "Cloudflare解析自动更新IP", + "home_url": "Module_cfddns.asp", + "md5": "a5412ac92b26967a619c8c458f839733", + "name": "cfddns", + "tar_url": "cfddns/cfddns.tar.gz", + "title": "", + "version": "1.2" + }, { "build_date": "2019-01-13_21:09:08", "description": "老板,来一斤虚拟内存~", @@ -72,7 +82,7 @@ } ], "home_url": "https://raw.githubusercontent.com/paldier/softcenter/master", - "md5": "55442664d9e425f5ce6a2a0375200c4d", + "md5": "87f69f0f5f47b7a4a17be3f2ef39ff93", "tar_url": "softcenter/softcenter.tar.gz", "version": "1.1.6" } \ No newline at end of file diff --git a/softcenter/config.json.js b/softcenter/config.json.js index 3912110..7ccf2e4 100644 --- a/softcenter/config.json.js +++ b/softcenter/config.json.js @@ -1,4 +1,4 @@ { "version":"1.1.6", -"md5":"55442664d9e425f5ce6a2a0375200c4d" +"md5":"87f69f0f5f47b7a4a17be3f2ef39ff93" } diff --git a/softcenter/softcenter.tar.gz b/softcenter/softcenter.tar.gz index cbf29e8..a61b6f0 100644 Binary files a/softcenter/softcenter.tar.gz and b/softcenter/softcenter.tar.gz differ diff --git a/softcenter/version b/softcenter/version index 428a71d..47bbda3 100644 --- a/softcenter/version +++ b/softcenter/version @@ -1,2 +1,2 @@ 1.1.6 -55442664d9e425f5ce6a2a0375200c4d +87f69f0f5f47b7a4a17be3f2ef39ff93