Don’t hardcode server into fedi-post.sh
It was previously set to jam.xwx.moe, now it’s exposed as a parameter.
This commit is contained in:
parent
92b9476c87
commit
3096ce5347
25
fedi-post.sh
25
fedi-post.sh
|
@ -75,7 +75,7 @@ post_media() {
|
|||
--header "Content-Type: multipart/form-data" \
|
||||
--form "file=@$media_file" \
|
||||
--form "description=$description" \
|
||||
"https://jam.xwx.moe/api/v1/media"
|
||||
"https://$SERVER/api/v1/media"
|
||||
}
|
||||
|
||||
|
||||
|
@ -89,7 +89,7 @@ post_status() {
|
|||
--header "Authorization: Bearer $FEDI_AUTH" \
|
||||
--header "Content-Type: application/json" \
|
||||
--data "$(post_json "$message" "$media_ids" "$spoiler" | tr -d '\n')" \
|
||||
"https://jam.xwx.moe/api/v1/statuses"
|
||||
"https://$SERVER/api/v1/statuses"
|
||||
}
|
||||
|
||||
|
||||
|
@ -119,10 +119,10 @@ post_archived_post() {
|
|||
|
||||
usage() {
|
||||
echo "usage: $(basename "$0") ARCHIVED-POST" 1>&2
|
||||
echo "" 1>&2
|
||||
echo "Will post a new status with the same text and attachments as one" 1>&2
|
||||
echo "from an archived post (in fedi-archive.sh format)." 1>&2
|
||||
echo "Your authorization key must be borrowed from your web-browser and" 1>&2
|
||||
echo 1>&2
|
||||
echo 'Will post a new status with the same text and attachments as one' 1>&2
|
||||
echo 'from an archived post (in fedi-archive.sh format).' 1>&2
|
||||
echo 'Your authorization key must be borrowed from your web-browser and' 1>&2
|
||||
echo 'placed in the $FEDI_AUTH environment variable.' 1>&2
|
||||
exit 2
|
||||
}
|
||||
|
@ -130,17 +130,18 @@ usage() {
|
|||
|
||||
if test -z "$FEDI_AUTH"; then
|
||||
echo 'You need to set the environment variable $FEDI_AUTH!' 1>&2
|
||||
echo 'You can find your auth key by examining the "Authentication: Bearer" header' 1>&2
|
||||
echo "used in requests by your server's web-client." 1>&2
|
||||
echo 'You can find your auth key by examining the “Authentication: Bearer” header' 1>&2
|
||||
echo 'used in requests by your server’s web-client.' 1>&2
|
||||
echo 'In Firefox, F12→Network.' 1>&2
|
||||
echo "" 1>&2
|
||||
echo 1>&2
|
||||
usage
|
||||
fi
|
||||
|
||||
FILE="$1"
|
||||
if test -z "$FILE" -o "$1" = "-h" -o "$1" = "--help"; then
|
||||
SERVER="$1"
|
||||
FILE="$2"
|
||||
if test -z "$SERVER" -o -z "$FILE" -o "$1" = "-h" -o "$1" = "--help"; then
|
||||
usage
|
||||
fi
|
||||
|
||||
|
||||
post_archived_post "$FILE"
|
||||
post_archived_post "$SERVER" "$FILE"
|
||||
|
|
|
@ -10,30 +10,31 @@
|
|||
#―――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――
|
||||
|
||||
usage() {
|
||||
echo "usage: $(basename "$0") USERNAME OLD-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
|
||||
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
|
||||
echo 'The env variable $FEDI_AUTH must contain your authentication key from your browser.' 1>&2
|
||||
exit 2
|
||||
}
|
||||
|
||||
|
||||
USERNAME="$1"
|
||||
SERVER="$2"
|
||||
if test -z "$USERNAME" -o -z "$SERVER" -o "$1" = "-h" -o "$1" = "--help"; then
|
||||
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
|
||||
usage
|
||||
fi
|
||||
|
||||
|
||||
mkdir archive
|
||||
cd archive/
|
||||
sh ../fedi-archive.sh "$USERNAME" "$SERVER"
|
||||
sh ../fedi-archive.sh "$USERNAME" "$OLD_SERVER"
|
||||
|
||||
|
||||
for file in ./*; do
|
||||
sh ../fedi-post.sh "$file" \
|
||||
sh ../fedi-post.sh "$NEW_SERVER" "$file" \
|
||||
>> imports-data.txt
|
||||
done
|
||||
|
||||
|
@ -41,12 +42,13 @@ done
|
|||
IFS="
|
||||
"
|
||||
|
||||
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."
|
||||
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
|
||||
read
|
||||
sleep 5
|
||||
echo "Alright, then, you brave fellow! I'm touched you trust me so much, though :o"
|
||||
echo 'Alright, then, you brave fellow! I’m touched you trust me so much, though :o'
|
||||
|
||||
for line in $(cat imports-data.txt); do
|
||||
sh ../pleroma-redate.sh "$(echo "$line" | awk '{print $3}')" \
|
||||
|
|
Ŝarĝante…
Reference in New Issue