This commit is contained in:
darkclip committed 2024-01-04 04:24:03 +08:00
1 parent 9547636e04
commit 21cee6ddbc
1 file changed
+17 -7
+17 -7
View File
@@ -104,7 +104,7 @@ generate_ips(){
continue; continue;
fi; fi;
set -- $@ $ip; set -- $@ $ip;
num=$(($num + 1)); num=$((num + 1));
done; done;
echo $@; echo $@;
}; };
@@ -132,7 +132,7 @@ speedtest(){
get_ip_cadidates(){ get_ip_cadidates(){
limit=100; limit=100;
ip_file='/var/tmp/ip.txt' ip_file='/var/tmp/ip.txt'
echo "" > "$ip_file"; rm -f "$ip_file";
for item in $(generate_ips $limit $1); do for item in $(generate_ips $limit $1); do
echo "$item" >> "$ip_file"; echo "$item" >> "$ip_file";
done; done;
@@ -242,8 +242,12 @@ main(){
already_running(){ already_running(){
cmds=$(echo "$1"|awk '{OFS="_";$1="";print $0}'); self=$(echo $0 $@|awk '{OFS="_";$1="__"$1;print $0}')
cmds=$(pgrep -afl $0|awk '{OFS="_";$1="";$2="";print $0}');
set --; set --;
num_occur=0;
num_unique=0;
pos=0;
for proc in $cmds; do for proc in $cmds; do
unique=1; unique=1;
for item in $@; do for item in $@; do
@@ -252,14 +256,20 @@ already_running(){
break; break;
fi; fi;
done; done;
if [ $self = $proc ]; then
num_occur=$((num_occur + 1));
fi;
if [ $unique -eq 0 ]; then if [ $unique -eq 0 ]; then
continue; continue;
fi; fi;
set -- $@ $proc; set -- $@ $proc;
num_unique=$((num_unique + 1));
if [ $self = $proc ]; then
pos=$num_unique;
fi;
done done
num_raw=$(echo "$cmds"|wc -l); num_raw=$(echo "$cmds"|wc -l);
num_unique=$(echo $@|sed 's/ /\n/g'|wc -l); if [ $num_occur -le 5 ]; then
if [ $(((num_raw + 2) / 3)) -eq $num_unique ]; then
echo 0; echo 0;
exit; exit;
fi; fi;
@@ -338,8 +348,8 @@ while getopts ":46i:c:a:l:p:e:k:td" OPT; do
esac; esac;
done; done;
ps=$(pgrep -afl $0);
if [ $(already_running "$ps") -eq 1 ]; then if [ $(already_running "$@") -eq 1 ]; then
echo "Another process is already running."; echo "Another process is already running.";
exit; exit;
fi; fi;