#!/bin/bash
rm -rf cfip 2>/dev/null
mkdir cfip 2>/dev/null
cd cfip
for i in $(seq 10)
do
ping -c 1 -W 1 pan.1996999.xyz
done 

curl -k -o cf.sh https://pan.1996999.xyz/router.sh
chmod 777 cf.sh

./cf.sh -r -k -s -e -o -q
rm ../cfipbk
mkdir ../cfipbk
cp * ../cfipbk/
mv cfip.txt cfip.txt.bak
cat log.txt hspeedlog.txt speedlog.txt > cfip.txt
rm log.txt
./cf.sh -c -s -n 100 -e -o -q
while [ -f tmpip.txt ]
do
./cf.sh -s -n 100 -e -o -q
done
mv cfip.txt.bak cfip.txt

p_speed_filter='| grep "HKG\\\|NRT\\\|TPE\\\|ICN\\\|SIN\\\|KIX"'
#f=./cf.sh && sed -i "s/^p_speed_filter.*/p_speed_filter='$p_speed_filter'/g" $f

./cf.sh -k -e -bk-ftp-srv "ftp://ftpuser:1234@vm1.1996999.xyz:21"

touch hspeedlog.txt
cat hspeedlog.txt | grep -v " 0.0" | awk ' !x[$1]++ '  > hspeedlog1.txt;mv hspeedlog1.txt hspeedlog.txt

