diff --git a/servers/scripts/check-failed.sh b/servers/scripts/check-failed.sh index 9708a89..7dd5b3e 100755 --- a/servers/scripts/check-failed.sh +++ b/servers/scripts/check-failed.sh @@ -1,3 +1,3 @@ #!/bin/sh FAILED_SQL=$HOME/servers/failed_sql.sql -test -e $FAILED_SQL && echo "$(wc -l $FAILED_SQL)" +test -e "$FAILED_SQL" && wc -l "$FAILED_SQL" diff --git a/servers/scripts/client-countries-today.sh b/servers/scripts/client-countries-today.sh index 4aee3f7..aa8ca4f 100755 --- a/servers/scripts/client-countries-today.sh +++ b/servers/scripts/client-countries-today.sh @@ -1,2 +1,11 @@ #!/bin/sh -cat /home/teeworlds/servers/versionsrv.log | grep -a "^\[`date +%y-%m-%d`" | grep "version request by" | sed -e "s/.*by //" | sort | uniq | while read line; do geoiplookup $line; done | sort | uniq -c | sort -gr + +grep -a "^\[$(date +%y-%m-%d)" /home/teeworlds/servers/versionsrv.log | \ + grep "version request by" | \ + sed -e "s/.*by //" | \ + sort | \ + uniq | while read -r line; \ + do + geoiplookup "$line"; + done | sort | uniq -c | sort -gr + diff --git a/servers/scripts/client-countries-yesterday.sh b/servers/scripts/client-countries-yesterday.sh index 5848a09..cac471f 100755 --- a/servers/scripts/client-countries-yesterday.sh +++ b/servers/scripts/client-countries-yesterday.sh @@ -1,2 +1,11 @@ #!/bin/sh -cat /home/teeworlds/servers/versionsrv.log | grep -a "^\[`date --date='1 days ago' +%y-%m-%d`" | grep "version request by" | sed -e "s/.*by //" | sort | uniq | while read line; do geoiplookup $line; done | sort | uniq -c | sort -gr + +grep -a "^\[$(date --date='1 days ago' +%y-%m-%d)" /home/teeworlds/servers/versionsrv.log | \ + grep "version request by" | \ + sed -e "s/.*by //" | \ + sort | \ + uniq | while read -r line; \ + do + geoiplookup "$line"; + done | sort | uniq -c | sort -gr + diff --git a/servers/scripts/client-players-today.sh b/servers/scripts/client-players-today.sh index 107084d..3d0c4c1 100755 --- a/servers/scripts/client-players-today.sh +++ b/servers/scripts/client-players-today.sh @@ -1,2 +1,6 @@ #!/bin/sh -cat /home/teeworlds/servers/versionsrv.log | grep -a "^\[`date +%Y-%m-%d`" | grep "version request by" | sed -e "s/.*by //" | sort | uniq | wc -l +grep -a "^\[$(date +%Y-%m-%d)" /home/teeworlds/servers/versionsrv.log | \ + grep "version request by" | \ + sed -e "s/.*by //" | \ + sort | uniq | wc -l + diff --git a/servers/scripts/client-players-yesterday.sh b/servers/scripts/client-players-yesterday.sh index e0dea0a..61afba8 100755 --- a/servers/scripts/client-players-yesterday.sh +++ b/servers/scripts/client-players-yesterday.sh @@ -1,2 +1,7 @@ #!/bin/sh -cat /home/teeworlds/servers/versionsrv.log | grep -a "^\[`date --date='1 days ago' +%Y-%m-%d`" | grep "version request by" | sed -e "s/.*by //" | sort | uniq | wc -l + +grep -a "^\[$(date --date='1 days ago' +%Y-%m-%d)" /home/teeworlds/servers/versionsrv.log | \ + grep "version request by" | \ + sed -e "s/.*by //" | \ + sort | uniq | wc -l + diff --git a/servers/scripts/countries-today.sh b/servers/scripts/countries-today.sh index 53bd36a..c3bab90 100755 --- a/servers/scripts/countries-today.sh +++ b/servers/scripts/countries-today.sh @@ -1,2 +1,11 @@ #!/bin/sh -cat /home/teeworlds/servers/servers/*log* | grep "^\[`date +%y-%m-%d`" | grep "player has entered the game" | sed -e "s/.*addr=\(.*\):.*/\1/" | sort | uniq | while read line; do geoiplookup $line; done | sort | uniq -c | sort -gr + +cat /home/teeworlds/servers/servers/*log* | \ + grep "^\[$(date +%y-%m-%d)" | \ + grep "player has entered the game" | \ + sed -e "s/.*addr=\(.*\):.*/\1/" | \ + sort | uniq | while read -r line; + do + geoiplookup "$line"; + done | sort | uniq -c | sort -gr + diff --git a/servers/scripts/countries-yesterday.sh b/servers/scripts/countries-yesterday.sh index 8a00042..fe9e3db 100755 --- a/servers/scripts/countries-yesterday.sh +++ b/servers/scripts/countries-yesterday.sh @@ -1,2 +1,11 @@ #!/bin/sh -cat /home/teeworlds/servers/servers/*log* | grep "^\[`date --date='1 days ago' +%y-%m-%d`" | grep "player has entered the game" | sed -e "s/.*addr=\(.*\):.*/\1/" | sort | uniq | while read line; do geoiplookup $line; done | sort | uniq -c | sort -gr +cat /home/teeworlds/servers/servers/*log* | \ + grep "^\[$(date --date='1 days ago' +%y-%m-%d)" | \ + grep "player has entered the game" | \ + sed -e "s/.*addr=\(.*\):.*/\1/" | \ + sort | \ + uniq | while read -r line; + do + geoiplookup "$line"; + done | sort | uniq -c | sort -gr + diff --git a/servers/scripts/players-today.sh b/servers/scripts/players-today.sh index 505bec0..99b7e46 100755 --- a/servers/scripts/players-today.sh +++ b/servers/scripts/players-today.sh @@ -1,2 +1,8 @@ #!/bin/sh -cat /home/teeworlds/servers/servers/*log* | grep -a "^\[`date +%Y-%m-%d`" | grep "player has entered the game" | sed -e "s/.*addr=\(.*\):.*/\1/" | sort | uniq | wc -l + +cat /home/teeworlds/servers/servers/*log* | \ + grep -a "^\[$(date +%Y-%m-%d)" | \ + grep "player has entered the game" | \ + sed -e "s/.*addr=\(.*\):.*/\1/" | \ + sort | uniq | wc -l + diff --git a/servers/scripts/players-yesterday.sh b/servers/scripts/players-yesterday.sh index 958946d..4454eda 100755 --- a/servers/scripts/players-yesterday.sh +++ b/servers/scripts/players-yesterday.sh @@ -1,2 +1,7 @@ #!/bin/sh -cat /home/teeworlds/servers/servers/*log* | grep -a "^\[`date --date='1 days ago' +%Y-%m-%d`" | grep "player has entered the game" | sed -e "s/.*addr=\(.*\):.*/\1/" | sort | uniq | wc -l +cat /home/teeworlds/servers/servers/*log* | \ + grep -a "^\[$(date --date='1 days ago' +%Y-%m-%d)" | \ + grep "player has entered the game" | \ + sed -e "s/.*addr=\(.*\):.*/\1/" | \ + sort | uniq | wc -l + diff --git a/servers/scripts/rebuild-votes.sh b/servers/scripts/rebuild-votes.sh index b2b0c69..b734cfc 100755 --- a/servers/scripts/rebuild-votes.sh +++ b/servers/scripts/rebuild-votes.sh @@ -1,7 +1,8 @@ #!/bin/sh -for t in `cat all-types`; do - tl=$(echo "$t" | tr A-Z a-z) - /home/django/bin/print_mapfile $t > "/home/teeworlds/servers/types/$tl/maps" -done +while IFS= read -r t +do + tl=$(echo "$t" | tr '[:upper:]' '[:lower:]') + /home/django/bin/print_mapfile "$t" > "/home/teeworlds/servers/types/$tl/maps" +done < all-types diff --git a/servers/scripts/update-everything.sh b/servers/scripts/update-everything.sh index 2ec61ad..330df12 100755 --- a/servers/scripts/update-everything.sh +++ b/servers/scripts/update-everything.sh @@ -1,8 +1,8 @@ #!/bin/bash -cd /home/teeworlds/servers +cd /home/teeworlds/servers || exit 1 -if [ $(cat /proc/loadavg|head -c1) -ge 2 ]; then +if [ "$(head -c1 /proc/loadavg)" -ge 2 ]; then #echo -e "Current load is > 2, not running." exit 1 fi @@ -22,15 +22,15 @@ cleanup() trap cleanup EXIT HUP INT QUIT TERM # Always call, even on success. -types=`cat all-types` +types=$(cat all-types) scripts/update-local.sh scripts/ranks.py $types # Only update the country-specific pages once per day #if test `find /var/www/ranks/ger/novice/index.html -mmin +1440`; then - grep name serverlist.json | sed -e 's/.*"name": "\(.*\)".*/\1/' | while read country; do - scripts/ranks.py --country=$country $types + grep name serverlist.json | sed -e 's/.*"name": "\(.*\)".*/\1/' | while read -r country; do + scripts/ranks.py --country="$country" $types done #fi diff --git a/servers/scripts/update-old-countries.sh b/servers/scripts/update-old-countries.sh index 1b1227c..b9cd781 100755 --- a/servers/scripts/update-old-countries.sh +++ b/servers/scripts/update-old-countries.sh @@ -1,9 +1,9 @@ #!/bin/bash -cd /home/teeworlds/servers +cd /home/teeworlds/servers || exit 1 -countries=`cat all-old-countries` -types=`cat all-types` +countries=$(cat all-old-countries) +types=$(cat all-types) for country in $countries; do - scripts/ranks.py --country=$country $types + scripts/ranks.py --country="$country" $types done