commit db302e0188e3f9cfec3c6af6916707035912bd68
parent 937cd90ffbd4c6342d38fab281452dad0de106af
Author: Nixx <nixx@firemail.cc>
Date: Thu, 27 May 2021 23:25:11 +0100
Configure path for check-up, for use in cron jobs
Diffstat:
1 file changed, 14 insertions(+), 11 deletions(-)
diff --git a/check-up b/check-up
@@ -1,4 +1,4 @@
-#!/bin/sh
+#!/bin/bash
#
# Copyright (C) <2021> <nixx@firemail.cc>
#
@@ -35,15 +35,14 @@ doconnections () {
COUNT=1
while [ $COUNT -le $LENGTH ]; do
- echo $DOMAIN
DOMAIN=$(head -n $COUNT "${1}" | tail -n 1)
# Find the domain in the output file
- POSITION=$(grep -n "^${DOMAIN}$" "${2}" | cut -d : -f 1)
+ POSITION=$(grep -n "^${DOMAIN} " "${2}" | cut -d : -f 1)
# And get the current number of occurences it has been down
- DOWNFOR=$(head -n $COUNT "${2}" | tail -n 1 | cut -d \ -f 2)
+ DOWNFOR=$(head -n $POSITION "${2}" | tail -n 1 | cut -d \ -f 2)
# If it doesn't connect, increment
- if ! ${TORSOCKS} curl -m $WAIT -s $DOMAIN > /dev/null; then
+ if ! timeout $WAIT ${TORSOCKS} curl -s "$DOMAIN" > /dev/null; then
echo "${DOMAIN} $((DOWNFOR + 1))" >> "${TMPOUT}"
# If it does, reset count to 0
else
@@ -57,14 +56,18 @@ doconnections () {
rm "${TMPOUT}"
}
-CLEARDOMAINS=webring.txt
-ONIONDOMAINS=webring_onion.txt
-CLEAROUTPUT=sites_up.txt
-ONIONOUTPUT=sites_up_onion.txt
+# For the benefit of cron jobs, set the path
+[ $# -ne 1 ] && echo "Path must be specified." && exit 1
+FILEPATH="${1}"
+
+CLEARDOMAINS=${FILEPATH}webring.txt
+ONIONDOMAINS=${FILEPATH}webring_onion.txt
+CLEAROUTPUT=${FILEPATH}sites_up.txt
+ONIONOUTPUT=${FILEPATH}sites_up_onion.txt
# If either domain file does not exist, exit
-[ ! -f "${CLEARDOMAINS}" ] && exit 1
-[ ! -f "${ONIONDOMAINS}" ] && exit 1
+[ ! -f "${CLEARDOMAINS}" ] && exit 2
+[ ! -f "${ONIONDOMAINS}" ] && exit 3
# If either output file does not exist, create it
[ ! -f "${CLEAROUTPUT}" ] && createfile "${CLEARDOMAINS}" "${CLEAROUTPUT}"