This commit is contained in:
darkclip committed 2024-01-03 23:40:57 +08:00
1 parent 600e2d27af
commit 8831abce3c
1 file changed
+8 -8
+8 -8
View File
@@ -132,6 +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";
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;
@@ -240,14 +241,12 @@ main(){
}; };
already_running(){ already_running(){
self=$1; cmds=$(echo "$1"|awk '{OFS="_";$1="";print $0}');
processes=$(pgrep -afl $self|awk '{$1="";print $0}');
set --; set --;
for proc in "$processes"; do for proc in $cmds; do
unique=1; unique=1;
for item in "$@"; do for item in $@; do
if [ "$item" = "$proc" ]; then if [ "$item" = "$proc" ]; then
unique=0; unique=0;
break; break;
@@ -256,9 +255,9 @@ already_running(){
if [ $unique -eq 0 ]; then if [ $unique -eq 0 ]; then
continue; continue;
fi; fi;
set -- $@ "$proc"; set -- $@ $proc;
done done
if [ $(echo "$processes"|wc -l) -eq $(echo "$@"|wc -l) ]; then if [ $(echo "$cmds"|wc -l) -eq $(echo "$@"|wc -l) ]; then
echo 0; echo 0;
else else
echo 1; echo 1;
@@ -337,7 +336,8 @@ while getopts ":46i:c:a:l:p:e:k:td" OPT; do
esac; esac;
done; done;
if [ $(already_running $0) -eq 1 ]; then ps=$(pgrep -afl $0);
if [ $(already_running "$ps") -eq 1 ]; then
echo "Another process is already running."; echo "Another process is already running.";
exit; exit;
fi; fi;