Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 31 additions & 4 deletions cfddns/cfddns/scripts/cfddns_config.sh
Original file line number Diff line number Diff line change
Expand Up @@ -128,14 +128,38 @@ check_update(){
echo_date "======================================"
}

# 计划运行自动更新
set_interval_update(){
username=`nvram show|grep http_username|awk -F '=' '{print $2}'`
filename=/tmp/var/spool/cron/crontabs/$username
if [ ! -f $filename ]
then
echo_date 计划文件不存在,将创建计划文件
touch $filename
else
echo_date 计划文件已存在
sed -i '/S99cfddns.sh/d' $filename
fi
[ "$cfddns_update_interval" = "" ] && cfddns_update_interval="30"
echo -e "\n*/$cfddns_update_interval * * * * sh /koolshare/init.d/S99cfddns.sh update">>$filename
sed -i '/^[ ]*$/d' $filename
echo_date 计划文件更新成功
service restart_crontab > NUL
echo_date 已启动计划
}

# add_cfddns_cru(){
# sed -i '/cfddns/d' /var/spool/cron/crontabs/* >/dev/null 2>&1
# cru a cfddns "0 */$cfddns_refresh_time * * * /koolshare/scripts/cfddns_config.sh update"
# }
#
# stop_cfddns(){
# sed -i '/cfddns/d' /var/spool/cron/crontabs/* >/dev/null 2>&1
# }

stop_cfddns(){
# sed -i '/cfddns/d' /var/spool/cron/crontabs/* >/dev/null 2>&1
username=`nvram show|grep http_username|awk -F '=' '{print $2}'`
filename=/tmp/var/spool/cron/crontabs/$username
sed -i '/S99cfddns.sh/d' $filename
}

# ====================================used by init or cru====================================
case $1 in
Expand All @@ -152,24 +176,27 @@ start)
echo_date "======================================" >> $LOG_FILE
echo_date "检测到网络拨号..." >> $LOG_FILE
check_update >> $LOG_FILE
set_interval_update >> $LOG_FILE
else
logger "[软件中心]: CloudFlare DDNS未设置开机启动,跳过!"
fi
;;
update)
echo_date 触发更新 >> $LOG_FILE
check_update >> $LOG_FILE
;;
esac
# ====================================submit by web====================================
case $2 in
1)
#此处为web提交动设计
#此处为web提交设计
echo "" > $LOG_FILE
http_response "$1"
if [ "$cfddns_enable" == "1" ];then
[ ! -L "/koolshare/init.d/S99cfddns.sh" ] && ln -sf /koolshare/scripts/cfddns_config.sh /koolshare/init.d/S99cfddns.sh
echo_date "======================================" >> $LOG_FILE
check_update >> $LOG_FILE
set_interval_update >> $LOG_FILE
else
echo_date "关闭CloudFlare DDNS!" >> $LOG_FILE
stop_cfddns
Expand Down
5 changes: 5 additions & 0 deletions cfddns/cfddns/uninstall.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,8 @@ rm -rf /koolshare/res/icon-cfddns.png
rm -rf /koolshare/scripts/cfddns*.sh
rm -rf /koolshare/scripts/uninstall_cfddns.sh
rm -rf /koolshare/webs/Module_cfddns.asp

# 删除crontab中的配置
username=`nvram show|grep http_username|awk -F '=' '{print $2}'`
filename=/tmp/var/spool/cron/crontabs/$username
sed -i '/S99cfddns.sh/d' $filename
12 changes: 11 additions & 1 deletion cfddns/cfddns/webs/Module_cfddns.asp
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ var dbus = {};
var _responseLen;
var noChange = 0;
var x = 5;
var params_inp = ['cfddns_email', 'cfddns_akey', 'cfddns_zid', 'cfddns_name', 'cfddns_domain', 'cfddns_ttl', 'cfddns_method'];
var params_inp = ['cfddns_email', 'cfddns_akey', 'cfddns_zid', 'cfddns_name', 'cfddns_domain', 'cfddns_ttl', 'cfddns_method', 'cfddns_update_interval'];
var params_chk = ['cfddns_enable', 'cfddns_proxied'];
//var params_chk = ['cfddns_enable', 'cfddns_proxied', 'cfddns_ipv6'];

Expand Down Expand Up @@ -156,6 +156,10 @@ function get_status1(){
}

function save(){
if($("#cfddns_update_interval").val()>59 || $("#cfddns_update_interval").val()<5){
alert("定时周期必须介于5与59之间");
return;
}
var dbus_new = {}
$("#show_btn2").trigger("click");
// collect data from input and checkbox
Expand Down Expand Up @@ -411,6 +415,12 @@ function reload_Soft_Center(){
<input type="text" maxlength="64" id="cfddns_ttl" name="cfddns_ttl" class="input_ss_table" style="width:130px;" autocomplete="off" autocorrect="off" autocapitalize="off" value="1" />
</td>
</tr>
<tr>
<th title="每多少分钟进行一次更新,最低5分钟,最多59分钟">定时周期(5~59分钟)</th>
<td>
<input type="number" min="5" max="59" id="cfddns_update_interval" name="cfddns_update_interval" class="input_ss_table" style="width:130px;" autocomplete="off" autocorrect="off" autocapitalize="off" value="5" />
</td>
</tr>
<tr>
<th title="开启后所有流量经Cloudflare在到路由器">Cloudflare代理(proxied)[?]</th>
<td>
Expand Down