deal_with_users.sh 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. #!/bin/bash
  2. # Copyright © 2023-2024 Jeffrey Cliff
  3. #
  4. # This program is free software: you can redistribute it and/or modify
  5. # it under the terms of the GNU General Public License as published by
  6. # the Free Software Foundation, either version 3 of the License, or (at
  7. # your option) any later version.
  8. #
  9. # This program is distributed in the hope that it will be useful, but
  10. # WITHOUT ANY WARRANTY; without even the implied warranty of
  11. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  12. # General Public License for more details.
  13. #
  14. # You should have received a copy of the GNU General Public License
  15. # along with this program. If not, see <https://www.gnu.org/licenses/>.
  16. HOW_SLOW_IS_SPC=59
  17. BASEDIR=/home/themusicgod1
  18. DBDIR=/home/themusicgod1/TDL
  19. echo "initializing /tmp/totallymissingdomains..."
  20. mv /tmp/totallymissingdomains /tmp/oldtotallymissingdomains 2>/dev/null
  21. mv /tmp/missingdomains /tmp/oldmissingdomains 2>/dev/null
  22. echo "OK"
  23. # 0. generate databases.db
  24. # 1.
  25. #sqlite3 database.db -line "select url from statuses;" | grep url | awk -F' ' '{print $3}'| awk -F'/' '{print $2"@" $1}' | sort | uniq > users.txt
  26. # get users script in aspublic
  27. # 2. move users to eva
  28. # 3.
  29. cat users.txt | grep -iv '@.*@.*' > users_malformatted.txt
  30. # 4.
  31. cat users_malformatted.txt | awk -F' ' '{print "@"$1}' >> users2.txt
  32. cat users.txt | grep -i '@.*@.*' >> users2.txt
  33. mv users2.txt users.txt
  34. #what should we do when the domain name or the username is update?
  35. # just grepping 'domain is' out should do the trick
  36. for x in `cat users.txt`; do
  37. #echo $x;
  38. howFar.sh $x | grep -iv 'domain is' |grep -i update | grep -iv 'other = ""' | grep -iv 'insert' | grep -iv '@'; done;
  39. #these i think can be just dropped in, no harm if they are dupes
  40. echo "done. press enter or something";
  41. read ;
  42. echo "preprocessing domains for cf. . . "
  43. echo "totally missing domains:"
  44. file -E /tmp/totallymissingdomains >/dev/null
  45. if [[ $? -eq "0" ]]; then
  46. # if it exists
  47. cat /tmp/totallymissingdomains
  48. fi
  49. file -E /tmp/missingdomains >/dev/null
  50. if [[ $? -eq "0" ]]; then
  51. # if it exists
  52. for x in `cat /tmp/missingdomains | sort | uniq `; do echo `is_cloudflare $x` | sed -e "s/\^//" | sed -e "s/\\$//" >> /tmp/cf_temp2 ; done
  53. cat /tmp/cf_temp2 | grep " yes" | awk -F' ' '{print "update instances set iscf=1 where name = \""$1"\";"}'
  54. cat /tmp/cf_temp2 | grep " no" | awk -F' ' '{print "update instances set iscf=0 where name = \""$1"\";"}'
  55. fi
  56. echo "domains preprocessed. check /tmp/cf_temp2. press enter or something";
  57. read ;
  58. for x in `cat users.txt`; do LINEME=`howFar.sh $x | grep -i insert `; echo $LINEME; sqlite3 ~/TDL/urls.db -line "$LINEME"; done
  59. #what we should do next is do some kind of error checking instead of sleep here - print OK if success
  60. #todo: make this dependent on max value
  61. #or make it 100?
  62. MAXLEVEL=`grep -i "maximum" $BASEDIR/tools/grabLaundry.sh | awk -F' ' '{print $3}' | awk -F')' '{print $1}'`".0"
  63. echo "selecting url from news where level > $MAXLEVEL; ..."
  64. sqlite3 $DBDIR/urls.db -line "select url from news where level > $MAXLEVEL;" | sed -e "s/url =//g"
  65. echo "put that into followme.txt"
  66. #we shoudl automate this
  67. # should print out the username of anyone this fails with in a greppable way
  68. # there's an issue in this with spc deal with spc users
  69. echo "when done. press enter or something";
  70. read ;
  71. for x in `cat followme.txt`; do
  72. echo $x;
  73. toot follow $x;
  74. sleep $HOW_SLOW_IS_SPC;
  75. done;
  76. check_for_banned_from_spc.sh users.txt
  77. echo "delete from news where level > $MAXLEVEL;"