123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192 |
- #!/bin/bash
- # Copyright © 2023-2024 Jeffrey Cliff
- #
- # This program is free software: you can redistribute it and/or modify
- # it under the terms of the GNU General Public License as published by
- # the Free Software Foundation, either version 3 of the License, or (at
- # your option) any later version.
- #
- # This program is distributed in the hope that it will be useful, but
- # WITHOUT ANY WARRANTY; without even the implied warranty of
- # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- # General Public License for more details.
- #
- # You should have received a copy of the GNU General Public License
- # along with this program. If not, see <https://www.gnu.org/licenses/>.
-
- TEMP=`mktemp`
- TEMP1=`mktemp`
- BASEDIR=/home/themusicgod1
- RED="\x1343"
- MAXLEVEL=`grep -i "maximum" $BASEDIR/tools/grabLaundry.sh | awk -F' ' '{print $8}' | awk -F')' '{print $1}'`".0"
- # MAXLEVEL="156.0"
- echo "maxlevel" $MAXLEVEL
- # MAXLEVEL="134.0"
- WHAT=$1
- echo $WHAT
- WHAT=`echo $WHAT | sed -e "s/www.threads.net/threads.net/"`
- echo $WHAT
- if [ -z $WHAT ] ; then
- echo "you need to give this script some input"
- exit;
- fi
- DB=/home/themusicgod1/TDL/urls.db
- FEDIDB=/home/themusicgod1/TDL/fedi.db
- LEVEL=`sqlite3 $DB -line "select level from news where url like \""$WHAT"\"" | grep -i 'level' | awk -F' ' '{print $3}'`
- if [[ -z $LEVEL ]]; then
- echo "zero - we have a new user"
- NEWID=`sqlite3 $DB -line "select max(id) from news" | grep -i 'id' | awk -F' ' '{print $3}'`
- # echo $NEWID
- NEWID2=`echo $NEWID "+ 1" | bc`
- # echo $NEWID2
- DOMAIN=`echo $WHAT | awk -F'@' '{print $3}'`;
- # NEWLEVEL=`grep -i $DOMAIN $BASEDIR/FediSus.html | head -n 1 | awk -F' ' '{print $2}'`
- # echo $NEWLEVEL
- # echo "we need to check if it's threads here";
- if [[ -z $DOMAIN ]]; then
- echo "something went wrong here : " $DOMAIN "should be a domain"
- echo "what is " $WHAT
- echo "this should give results:"
- echo $WHAT | grep -i '@.*@.*'
- if [[ $? -eq "1" ]]; then
- echo "you probably are missing a @ in your fedi id"
- fi
- exit
- fi
- if [ $DOMAIN = "www.threads.net" ]; then
- echo "its threads";
- DOMAIN="threads.net"
- echo "NEWID2" $WHAT
- WHAT=`echo $WHAT | sed -e "s/www.threads.net/threads.net/"`
- echo "NEWID2" $WHAT
- else
- echo "its' not threads";
- fi
- NEWLEVEL=`sqlite3 $FEDIDB -line "select level from instances where name like '"$DOMAIN"';" | grep -i 'level' | awk -F' ' '{print $3}'`
- HOWMANY=`how_many_arguments.sh $NEWLEVEL`
- if [[ $HOWMANY -gt 1 ]]; then
- setterm --foreground red
- echo "looks like we have too many levels: " $WHAT
- setterm --foreground default
- exit 1
- fi
- if [[ -z $NEWLEVEL ]]; then
- echo "insert into news values ("$NEWID2",\""$WHAT"\",0,'','','');"
- else
- echo "insert into news values ("$NEWID2",\""$WHAT"\","$NEWLEVEL",'','','');"
- fi
- exit
- fi
- ID=`sqlite3 $DB -line "select id from news where url like \""$WHAT"\"" | grep -i 'id' | awk -F' ' '{print $3}'`
- DOMAIN=`echo $1 | awk -F'@' '{print $3}'`
- if [ $DOMAIN = "www.threads.net" ]; then
- echo "its threads";
- DOMAIN="threads.net"
- else
- echo "its' not threads";
- fi
- echo "domain is " $DOMAIN
- # deal with the great cloudwall
- ISCLOUDWALL=`sqlite3 $FEDIDB -line "select iscf from instances where name = \"$DOMAIN\"" | sed -e "s/ iscf = //" `
- #echo sqlite3 $FEDIDB -line "select iscf from instances where name = \"$DOMAIN\""
- #echo "db" $FEDIDB
- #echo "cloudwall" $ISCLOUDWALL
- # thanks https://dev.to/dak425/how-to-check-if-a-string-is-empty-in-bash-264l
- ICWA=`how_many_arguments.sh $ISCLOUDWALL`
- if [[ $ICWA -gt 1 ]]; then
- setterm --foreground red
- echo "something up with " $DOMAIN
- setterm --foreground default
- fi
- echo "is cloudwall" $ISCLOUDWALL
- if [[ -z $ISCLOUDWALL ]] ; then
- setterm --foreground red
- echo "we are probably missing " $DOMAIN " in our database"
- echo "blocks:" `how_many_blocks_estimate.sh $DOMAIN`
- echo "cloudflare?" `is_cloudflare $DOMAIN`
- echo $DOMAIN >> /tmp/totallymissingdomains
- setterm --foreground default
- exit;
- fi
- if [ $ISCLOUDWALL -eq 2 ] ; then
- echo $DOMAIN " was in the database but cf status not known"
- setterm --foreground yellow
- echo "CLOUDFLARE - STATUS UNKNOWN"
- echo "cloudflare?" `is_cloudflare $DOMAIN`
- echo $DOMAIN >> /tmp/missingdomains
- setterm --foreground default
- fi
- if [ $ISCLOUDWALL -eq 1 ] ; then
- echo $DOMAIN
- setterm --foreground red
- echo "CLOUDFLARED"
- setterm --foreground default
- fi
- # cat FediSus.html | grep -i $DOMAIN | head -n 1 | awk -F' ' '{print $2}'
- #FEDILEVEL=`cat /home/themusicgod1/FediSus.html | grep -i $DOMAIN | head -n 1 | awk -F' ' '{print $2}'`
- #echo "domain:" $DOMAIN
- #echo sqlite3 $FEDIDB -line "select level from instances where name = '"$DOMAIN"';"
- FEDILEVEL=`sqlite3 $FEDIDB -line "select level from instances where name = '"$DOMAIN"';" | grep -i 'level' | awk -F' ' '{print $3}'`
- echo "instance level is" $FEDILEVEL
- echo "max LEVEL is " $MAXLEVEL
- echo "user LEVEL is " $LEVEL
- #echo "why:"
- echo "what:" $WHAT
- # this is the line where things can go wrong if there's 2 results
- # we don't want to incur another database hit.
- WHYLINE=`sqlite3 $DB -line "select why from news where url = \""$WHAT"\"" | grep -i 'why'`
- sqlite3 $DB -line "select why from news where url = \""$WHAT"\"" | grep -i 'why' > /tmp/whylines
- WHYLINELINES=`wc -l /tmp/whylines | awk -F' ' '{print $1}'`
- #WHYLINELINES=`echo $WHYLINE`
- echo "WHYWLINELINES " $WHYLINELINES
- if [[ $WHYLINELINES -gt 1 ]]; then
- echo "we have more than one line!!!!"
- setterm --foreground red
- echo "problem at $WHAT "
- setterm --foreground default
- exit
- fi
- echo $WHYLINE
- echo "we are over by:"
- echo "("$FEDILEVEL" - "$LEVEL")/"$MAXLEVEL
- echo "("$FEDILEVEL" - "$LEVEL")/"$MAXLEVEL | bc;
- LEVEL2=`echo $LEVEL + "("$FEDILEVEL" - "$LEVEL")/"$MAXLEVEL | bc`
- LEVEL3=`echo "("$FEDILEVEL" - "$LEVEL")/"$MAXLEVEL | bc`
- echo "level3" $LEVEL3
- if [[ -z $LEVEL3 ]]; then
- echo "this was crashing. its zero??"
- echo "fedi level again:" $FEDILEVEL
- echo "level again:" $LEVEL
- echo "maxlevel again:" $MAXLEVEL
- elif [[ $LEVEL3 -eq "0" ]] ; then
- echo "its zero"
- else
- echo "id" $ID
- echo "update news set level = " $LEVEL2 " where id = "$ID";"
- echo "WHAT Is " $WHAT
- fi
- whoisthis $WHAT
- grabSnowflake.sh $WHAT
|