From 8d804e63ab437fab8d1f1c8204c764316ddf2d4c Mon Sep 17 00:00:00 2001 From: Bob Mottram Date: Sat, 24 Feb 2018 10:41:10 +0000 Subject: [PATCH] Also preserve pleroma banner files --- src/freedombone-app-pleroma | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/src/freedombone-app-pleroma b/src/freedombone-app-pleroma index 7a214987..778af9d6 100755 --- a/src/freedombone-app-pleroma +++ b/src/freedombone-app-pleroma @@ -198,6 +198,29 @@ function expire_pleroma_posts { echo ' fi' >> $pleroma_expire_script echo 'done' >> $pleroma_expire_script echo '' >> $pleroma_expire_script + echo '# get the local banner files' >> $pleroma_expire_script + echo "banners=\$(sudo -u postgres psql -d pleroma -c \"select avatar->>'banner' from users where avatar->>'url' like '%${domain_name}%'\")" >> $pleroma_expire_script + echo '' >> $pleroma_expire_script + echo '# copy the banner files to a temporary directory' >> $pleroma_expire_script + echo 'arr=( $banners )' >> $pleroma_expire_script + echo 'for i in "${arr[@]}"; do' >> $pleroma_expire_script + echo ' if [[ "$i" == *'/media/'* ]]; then' >> $pleroma_expire_script + echo " imagefile=/etc/pleroma/uploads/\$(echo \$i | sed 's|\"||g' | sed 's|,||g' | awk -F '/media/' '{print \$2}');" >> $pleroma_expire_script + echo ' if [ -f $imagefile ]; then' >> $pleroma_expire_script + echo " imagedir=/etc/pleroma/uploads/\$(echo \$i | sed 's|\"||g' | sed 's|,||g' | awk -F '/media/' '{print \$2}' | awk -F '/' '{print \$1}')" >> $pleroma_expire_script + echo ' nowdate=$(date +%s)' >> $pleroma_expire_script + echo ' sinceepoch=$(date +%s -r $imagefile)' >> $pleroma_expire_script + echo ' daysold=$((($nowdate - $sinceepoch) / 86400))' >> $pleroma_expire_script + echo " if [ \$daysold -ge ${expire_days_files_threshold} ]; then" >> $pleroma_expire_script + echo ' if [ ! -d $imagedir ]; then' >> $pleroma_expire_script + echo ' mkdir $imagedir' >> $pleroma_expire_script + echo ' fi' >> $pleroma_expire_script + echo ' cp -rp $imagefile $imagedir' >> $pleroma_expire_script + echo ' fi' >> $pleroma_expire_script + echo ' fi' >> $pleroma_expire_script + echo ' fi' >> $pleroma_expire_script + echo 'done' >> $pleroma_expire_script + echo '' >> $pleroma_expire_script echo '# delete old files' >> $pleroma_expire_script echo "find /etc/pleroma/uploads/* -mtime +${expire_days_files} -exec rm -rf {} +" >> $pleroma_expire_script echo '' >> $pleroma_expire_script