pleroma-migrate.sh 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. #!/bin/sh
  2. #―――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――
  3. # Name: pleroma-migrate.sh
  4. # Desc: Downloads posts from a pleroma account on a foreign server, to post them
  5. # on your new server. Then directly edits Pleroma's database to match the
  6. # new posts' dates with the original posts' dates.
  7. # Reqs: fedi-post.sh, fedi-archive.sh, pleroma-redate.sh
  8. # Date: 2023-05-06
  9. # Auth: @jadedctrl@jam.xwx.moe
  10. #―――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――
  11. usage() {
  12. echo "usage: $(basename "$0") USERNAME OLD-SERVER" 1>&2
  13. echo "" 1>&2
  14. echo "Will archive all posts from your old account (fedi-archive.sh)," 1>&2
  15. echo "post them to your new one (fedi-post.sh), and then modify Pleroma's" 1>&2
  16. echo "database to match the copy-posts' creation dates with the original posts." 1>&2
  17. echo 'The env variable $FEDI_AUTH must contain your authentication key from your browser.' 1>&2
  18. exit 2
  19. }
  20. USERNAME="$1"
  21. SERVER="$2"
  22. if test -z "$USERNAME" -o -z "$SERVER" -o "$1" = "-h" -o "$1" = "--help"; then
  23. usage
  24. fi
  25. mkdir archive
  26. cd archive/
  27. sh ../fedi-archive.sh "$USERNAME" "$SERVER"
  28. for file in ./*; do
  29. sh ../fedi-post.sh "$file" \
  30. >> imports-data.txt
  31. done
  32. IFS="
  33. "
  34. echo "It's time to re-date your posts!"
  35. echo "Are you suuuuuuuuuuuuure you wanna risk your database? Do a backup, first!"
  36. echo "^C now, before you risk it! Hit ENTER, if you're sure."
  37. read
  38. sleep 5
  39. echo "Alright, then, you brave fellow! I'm touched you trust me so much, though :o"
  40. for line in $(cat imports-data.txt); do
  41. sh ../pleroma-redate.sh "$(echo "$line" | awk '{print $3}')" \
  42. "$(echo "$line" | awk '{print $2}')"
  43. done