nos/run

42 lines
1.9 KiB
Plaintext
Raw Normal View History

2023-09-04 19:41:32 +00:00
#!/bin/bash
2023-09-05 19:13:28 +00:00
count=0; lim=15000;
2023-09-04 19:41:32 +00:00
while [ $count -lt $lim ]; do
finishcount=0;
pid=$(cat pid);
echo -n -e "${pid}\t"
2023-09-04 19:59:29 +00:00
url=$(./getlink);
2023-09-04 19:41:32 +00:00
2023-09-04 19:59:29 +00:00
# The ./getlink checks for a 404.
2023-09-04 19:41:32 +00:00
# This continues a few post id's down to make sure it's really reached the end.
# The post id will not be incremented if there are five 404's in a row.
2023-09-05 19:13:28 +00:00
if [ "$url" = "error finish" ]; then echo -n " it"; finishcount=$(( $finishcount + 1 ));
if [ "$(./getlink $(( $pid+1 )) )" = "error finish" ]; then echo -n "'"; finishcount=$(( $finishcount + 1 ));
if [ "$(./getlink $(( $pid+2 )) )" = "error finish" ]; then echo -n "s"; finishcount=$(( $finishcount + 1 ));
if [ "$(./getlink $(( $pid+3 )) )" = "error finish" ]; then echo -n "..."; finishcount=$(( $finishcount + 1 ));
if [ "$(./getlink $(( $pid+4 )) )" = "error finish" ]; then echo -n " so"; finishcount=$(( $finishcount + 1 ));
2023-09-05 18:09:12 +00:00
fi; fi; fi; fi; echo -n " -it's over- ";
2023-09-04 19:41:32 +00:00
fi
2023-09-05 18:51:38 +00:00
if [ "$finishcount" -gt 0 ] && [ "$finishcount" -lt 5 ]; then echo " -we're back- "; url=$(./getlink); else echo; fi;
2023-09-04 20:23:00 +00:00
# Pause execution if rate limit has been reached
2023-09-05 19:13:28 +00:00
if [ "$url" = "error rlimit" ]; then echo "rlimit.. sleeping 60 (1)"; sleep 60; url=$(./getlink);
if [ "$url" = "error rlimit" ]; then echo "rlimit.. sleeping 600 (2)"; sleep 600; url=$(./getlink);
2023-09-04 20:23:00 +00:00
if [ "$url" = "error rlimit" ]; then echo "rlimit.. sleeping 1140 (3)"; sleep 1140; url=$(./getlink);
2023-09-05 06:17:54 +00:00
if [ "$url" = "error rlimit" ]; then echo "rlimit.. sleeping 1940 (4)"; sleep 1940; url=$(./getlink);
2023-09-04 20:23:00 +00:00
fi; fi; fi; fi;
2023-09-04 19:41:32 +00:00
echo "$url";
2023-09-04 19:59:29 +00:00
# If ./getlink returns the URL, then it matched the pattern and the returned URL is the fixed one so it posts a comment.
if [ $(echo "$url" | cut -d ' ' -f1) != "error" ]; then echo "POST IT"; $(./reply_post "$pid" "$url" > /dev/null); fi;
2023-09-04 19:41:32 +00:00
# The post id will not be incremented if there are five 404's in a row.
2023-09-05 06:16:19 +00:00
if [ $finishcount -lt 5 ]; then echo $(( $pid + 1 )) > pid; fi;
count=$(( $count + 1 ));
2023-09-04 19:41:32 +00:00
done;