deal_with_users.sh 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  1. #!/bin/bash
  2. # Copyright © 2016-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 [dont press enter yet]"
  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. echo "checking for lower/uppercase conflicts:"
  35. for x in `cat users.txt`; do
  36. check_user_for_caps.sh $x | awk -F'=' '{print $2}';
  37. done;
  38. echo "press enter to continue"
  39. read
  40. #what should we do when the domain name or the username is update?
  41. # just grepping 'domain is' out should do the trick
  42. for x in `cat users.txt`; do
  43. #echo $x;
  44. howFar.sh $x | grep -iv 'domain is' |grep -i update | grep -iv 'other = ""' | grep -iv 'insert' | grep -iv '@'; done;
  45. #these i think can be just dropped in, no harm if they are dupes
  46. echo "done. press enter or something";
  47. read ;
  48. echo "preprocessing domains for cf. . . "
  49. echo "totally missing domains:"
  50. file -E /tmp/totallymissingdomains >/dev/null
  51. if [[ $? -eq "0" ]]; then
  52. # if it exists
  53. cat /tmp/totallymissingdomains | sort | uniq
  54. fi
  55. echo "done."
  56. echo "press enter to continue"
  57. read
  58. echo "doing iscf part..."
  59. file -E /tmp/missingdomains >/dev/null
  60. if [[ $? -eq "0" ]]; then
  61. # if it exists
  62. for x in `cat /tmp/missingdomains | sort | uniq `; do echo $x `is_cloudflare $x` | sed -e "s/\^//" | sed -e "s/\\$//" > /tmp/cf_temp2 ;
  63. cat /tmp/cf_temp2 | grep " yes" | awk -F' ' '{print "update instances set iscf=1 where name = \""$1"\";"}'
  64. cat /tmp/cf_temp2 | grep " no" | awk -F' ' '{print "update instances set iscf=0 where name = \""$1"\";"}'
  65. done;
  66. fi
  67. echo "domains preprocessed. check /tmp/cf_temp2. press enter or something";
  68. read ;
  69. for x in `cat users.txt`; do echo $x; LINEME=`howFar.sh $x | grep -i insert `; echo $LINEME; sqlite3 ~/TDL/urls.db -line "$LINEME"; done
  70. #what we should do next is do some kind of error checking instead of sleep here - print OK if success
  71. #todo: make this dependent on max value
  72. #or make it 100?
  73. MAXLEVEL=`grep -i "maximum" $BASEDIR/tools/grabLaundry.sh | awk -F' ' '{print $3}' | awk -F')' '{print $1}'`".0"
  74. echo "selecting url from news where level > $MAXLEVEL; ..."
  75. sqlite3 $DBDIR/urls.db -line "select url from news where level > $MAXLEVEL;" | sed -e "s/url =//g"
  76. echo "put that into followme.txt"
  77. #we shoudl automate this
  78. # should print out the username of anyone this fails with in a greppable way
  79. # there's an issue in this with spc deal with spc users
  80. echo "when done. press enter or something";
  81. read ;
  82. for x in `cat followme.txt`; do
  83. echo $x;
  84. toot follow $x;
  85. sleep $HOW_SLOW_IS_SPC;
  86. done;
  87. check_for_banned_from_spc.sh users.txt
  88. echo "delete from news where level > $MAXLEVEL;"