OpenClash: bump to latest git HEAD

This commit is contained in:
CN_SZTL 2020-02-20 02:54:21 +08:00
parent 0639c6e428
commit 549aeffd76
No known key found for this signature in database
GPG Key ID: 6850B6345C862176
4 changed files with 49 additions and 18 deletions

View File

@ -26,7 +26,10 @@ PROXY_ROUTE_TABLE="0x162"
add_cron()
{
[ -z "$(grep "openclash.sh" "$CRON_FILE" 2>/dev/null)" ] && {
[ "$(uci get openclash.config.auto_update 2>/dev/null)" -eq 1 ] && echo "0 $(uci get openclash.config.auto_update_time 2>/dev/null) * * $(uci get openclash.config.config_update_week_time 2>/dev/null) /usr/share/openclash/openclash.sh" >> $CRON_FILE
[ "$(uci get openclash.config.auto_update 2>/dev/null)" -eq 1 ] && [ "$(uci get openclash.config.config_auto_update_mode 2>/dev/null)" -ne 1 ] && echo "0 $(uci get openclash.config.auto_update_time 2>/dev/null) * * $(uci get openclash.config.config_update_week_time 2>/dev/null) /usr/share/openclash/openclash.sh" >> $CRON_FILE
}
[ -z "$(grep "openclash.sh" "$CRON_FILE" 2>/dev/null)" ] && {
[ "$(uci get openclash.config.auto_update 2>/dev/null)" -eq 1 ] && [ "$(uci get openclash.config.config_auto_update_mode 2>/dev/null)" -eq 1 ] && echo "*/$(uci get openclash.config.config_update_interval 2>/dev/null) * * * * /usr/share/openclash/openclash.sh" >> $CRON_FILE
}
[ -z "$(grep "openclash_rule.sh" "$CRON_FILE" 2>/dev/null)" ] && {
[ "$(uci get openclash.config.other_rule_auto_update 2>/dev/null)" -eq 1 ] && echo "0 $(uci get openclash.config.other_rule_update_day_time 2>/dev/null) * * $(uci get openclash.config.other_rule_update_week_time 2>/dev/null) /usr/share/openclash/openclash_rule.sh" >> $CRON_FILE
@ -621,7 +624,7 @@ start()
status=$(ps|grep -c /etc/init.d/openclash)
[ "$status" -gt "3" ] && exit 0
if [ -z "$CONFIG_FILE" ]; then
if [ -z "$CONFIG_FILE" ] || [ ! -f "$CONFIG_FILE" ]; then
CONFIG_NAME=$(ls -lt /etc/openclash/config/ | grep -E '.yaml|.yml' | head -n 1 |awk '{print $9}')
if [ ! -z "$CONFIG_NAME" ]; then
uci set openclash.config.config_path="/etc/openclash/config/$CONFIG_NAME"
@ -799,6 +802,12 @@ EOF
ip link set clash0 up
ip route replace default dev clash0 table "$PROXY_ROUTE_TABLE"
elif [ "$en_mode_tun" = "1" ]; then
TUN_WAIT=0
while ( [ ! -z "$(pidof clash)" ] && [ -z "$(ip route list |grep utun)" ] && [ "$TUN_WAIT" -le 3 ] )
do
TUN_WAIT=$(expr "$TUN_WAIT" + 1)
sleep 2
done
ip route replace default dev utun table "$PROXY_ROUTE_TABLE"
fi
ip rule add fwmark "$PROXY_FWMARK" table "$PROXY_ROUTE_TABLE"
@ -839,6 +848,7 @@ EOF
echo "${LOGTIME} OpenClash Start Successful, Please Note That Network May Abnormal With IPV6's DHCP Server" >> $LOG_FILE
sleep 10
fi
echo "OpenClash Already Start"
echo "" >$START_LOG
else
if [ "$rule_source" != 0 ] || [ "$enable_custom_clash_rules" != 0 ]; then
@ -866,6 +876,7 @@ EOF
echo "${LOGTIME} OpenClash Start Successful, Please Note That Network May Abnormal With IPV6's DHCP Server" >> $LOG_FILE
sleep 10
fi
echo "OpenClash Already Start"
echo "" >$START_LOG
else
echo "错误: OpenClash 启动失败,请到日志页面查看详细错误信息!" >$START_LOG

View File

@ -26,7 +26,15 @@ o:value("0", translate("Disable"))
o:value("1", translate("Enable"))
o.default=0
o = s:option(ListValue, "config_auto_update_mode", translate("Update Mode"))
o:depends("auto_update", "1")
o:value("0", translate("Appointment Mode"))
o:value("1", translate("Loop Mode"))
o.default=0
o.rmempty = true
o = s:option(ListValue, "config_update_week_time", translate("Update Time (Every Week)"))
o:depends("config_auto_update_mode", "0")
o:value("*", translate("Every Day"))
o:value("1", translate("Every Monday"))
o:value("2", translate("Every Tuesday"))
@ -36,26 +44,21 @@ o:value("5", translate("Every Friday"))
o:value("6", translate("Every Saturday"))
o:value("0", translate("Every Sunday"))
o.default=1
o.rmempty = true
o = s:option(ListValue, "auto_update_time", translate("Update time (every day)"))
o:depends("config_auto_update_mode", "0")
for t = 0,23 do
o:value(t, t..":00")
end
o.default=0
o.rmempty = false
o.rmempty = true
o = s:option(Button, translate("Config File Update"))
o.title = translate("Update Subcription")
o.inputtitle = translate("Check And Update")
o.inputstyle = "reload"
o.write = function()
m.uci:set("openclash", "config", "enable", 1)
m.uci:commit("openclash")
local config_name=string.sub(luci.sys.exec("uci get openclash.config.config_path"), 23, -2)
SYS.call("rm -rf /etc/openclash/backup/* 2>/dev/null")
SYS.call("/usr/share/openclash/openclash.sh >/dev/null 2>&1 &")
HTTP.redirect(DISP.build_url("admin", "services", "openclash"))
end
o = s:option(Value, "config_update_interval", translate("Update Interval(min)"))
o.default="60"
o.datatype = "integer"
o:depends("config_auto_update_mode", "1")
o.rmempty = true
-- [[ Edit Server ]] --
s = m:section(TypedSection, "config_subscribe")
@ -86,14 +89,14 @@ o:value("clash", translate("Clash"))
o:value("v2rayn", translate("V2rayN"))
o:value("surge", translate("Surge"))
o.default="clash"
o.rempty = false
o.rempty = false
---- address
o = s:option(Value, "address", translate("Subscribe Address"))
o.description = font_red..bold_on..translate("(Not Null)")..bold_off..font_off
o.placeholder = translate("Not Null")
o.datatype = "or(host, string)"
o.rmempty = true
o.rmempty = false
---- key
o = s:option(DynamicList, "keyword", font_red..bold_on..translate("Keyword Match")..bold_off..font_off)
@ -119,7 +122,8 @@ o.inputstyle = "apply"
o.write = function()
m.uci:set("openclash", "config", "enable", 1)
m.uci:commit("openclash")
SYS.call("/etc/init.d/openclash restart >/dev/null 2>&1 &")
SYS.call("rm -rf /etc/openclash/backup/* 2>/dev/null")
SYS.call("/usr/share/openclash/openclash.sh >/dev/null 2>&1 &")
HTTP.redirect(DISP.build_url("admin", "services", "openclash"))
end

View File

@ -2,6 +2,8 @@
CLASH="/etc/openclash/clash"
CLASH_CONFIG="/etc/openclash"
LOG_FILE="/tmp/openclash.log"
PROXY_FWMARK="0x162"
PROXY_ROUTE_TABLE="0x162"
enable_redirect_dns=$(uci get openclash.config.enable_redirect_dns 2>/dev/null)
dns_port=$(uci get openclash.config.dns_port 2>/dev/null)
disable_masq_cache=$(uci get openclash.config.disable_masq_cache 2>/dev/null)
@ -20,6 +22,8 @@ if [ "$enable" -eq 1 ]; then
echo "${LOGTIME} Watchdog: Clash Core Problem, Restart." >> $LOG_FILE
nohup "$CLASH" -d "$CLASH_CONFIG" -f "$CONFIG_FILE" >> $LOG_FILE 2>&1 &
sleep 3
ip route replace default dev utun table "$PROXY_ROUTE_TABLE" 2>/dev/null
ip rule add fwmark "$PROXY_FWMARK" table "$PROXY_ROUTE_TABLE" 2>/dev/null
/usr/share/openclash/openclash_history_set.sh
else
echo "${LOGTIME} Watchdog: Already Restart 3 Times With Clash Core Problem, Auto-Exit." >> $LOG_FILE

View File

@ -274,6 +274,18 @@ msgstr "更新订阅配置"
msgid "Update time (every day)"
msgstr "更新时间(每天)"
msgid "Update Interval(min)"
msgstr "更新间隔(分钟)"
msgid "Update Mode"
msgstr "更新模式"
msgid "Appointment Mode"
msgstr "预约"
msgid "Loop Mode"
msgstr "循环"
msgid "Auto Update"
msgstr "自动更新"