2023-05-06 11:27:09 -05:00
|
|
|
|
#!/bin/sh
|
|
|
|
|
#―――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――
|
|
|
|
|
# Name: pleroma-migrate.sh
|
|
|
|
|
# Desc: Downloads posts from a pleroma account on a foreign server, to post them
|
|
|
|
|
# on your new server. Then directly edits Pleroma's database to match the
|
|
|
|
|
# new posts' dates with the original posts' dates.
|
|
|
|
|
# Reqs: fedi-post.sh, fedi-archive.sh, pleroma-redate.sh
|
|
|
|
|
# Date: 2023-05-06
|
|
|
|
|
# Auth: @jadedctrl@jam.xwx.moe
|
|
|
|
|
#―――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――
|
|
|
|
|
|
|
|
|
|
usage() {
|
2024-02-13 09:54:58 -06:00
|
|
|
|
echo "usage: $(basename "$0") OLD-USERNAME OLD-SERVER NEW-SERVER" 1>&2
|
|
|
|
|
echo 1>&2
|
|
|
|
|
echo 'Will archive all posts from your old account (fedi-archive.sh),' 1>&2
|
|
|
|
|
echo 'post them to your new one (fedi-post.sh), and then modify Pleroma’s' 1>&2
|
|
|
|
|
echo 'database to match the copy-posts’ creation dates with the original posts.' 1>&2
|
2023-05-06 11:27:09 -05:00
|
|
|
|
echo 'The env variable $FEDI_AUTH must contain your authentication key from your browser.' 1>&2
|
|
|
|
|
exit 2
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
USERNAME="$1"
|
2024-02-13 09:54:58 -06:00
|
|
|
|
OLD_SERVER="$2"
|
|
|
|
|
NEW_SERVER="$3"
|
|
|
|
|
if test -z "$USERNAME" -o -z "$OLD_SERVER" -o -z "$NEW_SERVER" -o "$1" = "-h" -o "$1" = "--help"; then
|
2023-05-06 11:27:09 -05:00
|
|
|
|
usage
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
mkdir archive
|
|
|
|
|
cd archive/
|
2024-02-13 09:54:58 -06:00
|
|
|
|
sh ../fedi-archive.sh "$USERNAME" "$OLD_SERVER"
|
2023-05-06 11:27:09 -05:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
for file in ./*; do
|
2024-02-13 09:54:58 -06:00
|
|
|
|
sh ../fedi-post.sh "$NEW_SERVER" "$file" \
|
2023-05-06 11:27:09 -05:00
|
|
|
|
>> imports-data.txt
|
|
|
|
|
done
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
IFS="
|
|
|
|
|
"
|
|
|
|
|
|
2024-02-13 09:54:58 -06:00
|
|
|
|
echo 'It’s time to re-date your posts!'
|
|
|
|
|
echo 'Are you suuuuuuuuuuuuure you wanna risk your database? Do a backup, first!'
|
|
|
|
|
echo '^C now, before you risk it! Hit ENTER, if you’re sure.'
|
|
|
|
|
read
|
2023-05-06 11:27:09 -05:00
|
|
|
|
read
|
|
|
|
|
sleep 5
|
2024-02-13 09:54:58 -06:00
|
|
|
|
echo 'Alright, then, you brave fellow! I’m touched you trust me so much, though :o'
|
2023-05-06 11:27:09 -05:00
|
|
|
|
|
|
|
|
|
for line in $(cat imports-data.txt); do
|
|
|
|
|
sh ../pleroma-redate.sh "$(echo "$line" | awk '{print $3}')" \
|
|
|
|
|
"$(echo "$line" | awk '{print $2}')"
|
|
|
|
|
done
|