Also preserve pleroma banner files
This commit is contained in:
parent
5c8b3c7ab9
commit
8d804e63ab
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue