Skip to content

Commit

Permalink
1.5.5a
Browse files Browse the repository at this point in the history
  • Loading branch information
frainzy1477 committed Feb 9, 2020
1 parent ba9297d commit bba588c
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 37 deletions.
36 changes: 20 additions & 16 deletions root/etc/init.d/clash
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ CRON_FILE="/etc/crontabs/root"
CONFIG_YAML="/etc/clash/config.yaml"
CONFIG_YAML_PATH=$(uci get clash.config.use_config 2>/dev/null)


CUSLIST="/tmp/dnsmasq.d/custom_list.conf"
CUSLITT="/tmp/dnsmasq.clash"
CUSLISTV="/var/dnsmasq.d/custom_list.conf"
Expand Down Expand Up @@ -298,6 +297,9 @@ custom_list() {
sh /usr/share/clash/list.sh >/dev/null 2>&1
}

watchdog() {
nohup /usr/share/clash/clash-watchdog.sh >/dev/null 2>&1
}
start(){
#===========================================================================================================================
lang=$(uci get luci.main.lang 2>/dev/null)
Expand Down Expand Up @@ -446,8 +448,19 @@ if [ -f $CONFIG_YAML ] && [ "$(ls -l $CONFIG_YAML|awk '{print int($5/1024)}')"
fi

fi

sleep 2


if [ "${lang}" == "en" ] || [ $lang == "auto" ];then
echo "Setting Cron Job" >$REAL_LOG
add_cron
elif [ "${lang}" == "zh_cn" ];then
echo "设置Cron" >$REAL_LOG
add_cron

bash /usr/share/clash/restore.sh >/dev/null 2>&1
fi


sleep 1

Expand All @@ -457,19 +470,18 @@ if [ -f $CONFIG_YAML ] && [ "$(ls -l $CONFIG_YAML|awk '{print int($5/1024)}')"
echo "设置 Clash iptables" >$REAL_LOG
fi

if [ "$(uci get firewall.@defaults[0].forward)" != "ACCEPT" ]; then
if [ "$(uci get firewall.@defaults[0].forward)" != "ACCEPT" ]; then
uci set firewall.@defaults[0].forward=ACCEPT >/dev/null 2>&1
uci commit firewall >/dev/null 2>&1
/etc/init.d/firewall restart >/dev/null 2>&1
fi
fi

sleep 2
sleep 2
rules >/dev/null 2>&1

custom_list >/dev/null 2>&1
sleep 1


if [ "${lang}" == "en" ] || [ $lang == "auto" ];then
echo "Restarting Dnsmasq " >$REAL_LOG
elif [ "${lang}" == "zh_cn" ];then
Expand All @@ -478,29 +490,21 @@ if [ -f $CONFIG_YAML ] && [ "$(ls -l $CONFIG_YAML|awk '{print int($5/1024)}')"

/etc/init.d/dnsmasq restart >/dev/null 2>&1
sleep 1

if pidof clash >/dev/null; then
add_cron

if [ "${lang}" == "en" ] || [ $lang == "auto" ];then
echo "Setting Cron Job" >$REAL_LOG
sleep 1
echo "Clash Started Successfully " >$REAL_LOG
sleep 2
echo "Clash is Running " >$REAL_LOG
sleep 2
echo "Clash for OpenWRT" >$REAL_LOG
elif [ "${lang}" == "zh_cn" ];then
echo "设置Cron" >$REAL_LOG
sleep 1
echo "Clash 启动成功,请等待服务器上线!" >$REAL_LOG
sleep 2
echo "Clash运行中" >$REAL_LOG
sleep 2
echo "Clash for OpenWRT" >$REAL_LOG
fi
nohup /usr/share/clash/clash-watchdog.sh >/dev/null 2>&1

fi
watchdog >/dev/null 2>&1
else
if [ "${lang}" == "en" ] || [ $lang == "auto" ];then
echo " $(date "+%Y-%m-%d %H:%M:%S") - problem with config.yaml, config.yaml is either empty or not found " >> /usr/share/clash/clash.txt
Expand Down
20 changes: 19 additions & 1 deletion root/usr/share/clash/clash-watchdog.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/bin/sh

sleeptime=300
logfile="/tmp/clash.log"
CLASH="/etc/clash/clash"
Expand All @@ -17,6 +17,24 @@ clean_log(){

}


if [ -f /usr/share/clashbackup/history ];then
HISTORY_PATH="/usr/share/clashbackup/history"
SECRET=$(uci get clash.config.dash_pass 2>/dev/null)
LAN_IP=$(uci get network.lan.ipaddr 2>/dev/null |awk -F '/' '{print $1}' 2>/dev/null)
PORT=$(uci get clash.config.dash_port 2>/dev/null)

if [ ! -z "$(grep "#*#" "$HISTORY_PATH")" ]; then
cat $HISTORY_PATH |while read line
do
GORUP_NAME=$(echo $line |awk -F '#*#' '{print $1}')
NOW_NAME=$(echo $line |awk -F '#*#' '{print $3}')
curl -H "Authorization: Bearer ${SECRET}" -H "Content-Type:application/json" -X PUT -d '{"name":"'"$NOW_NAME"'"}' http://"$LAN_IP":"$PORT"/proxies/"$GORUP_NAME" >/dev/null 2>&1
done
fi
fi


while [ $enable -eq 1 ];
do
curtime=`date "+%H:%M:%S"`
Expand Down
20 changes: 0 additions & 20 deletions root/usr/share/clash/restore.sh

This file was deleted.

0 comments on commit bba588c

Please sign in to comment.