Compare commits
2 commits
b0fde6dc39
...
01c3931525
Author | SHA1 | Date | |
---|---|---|---|
01c3931525 | |||
82a9f96770 |
2 changed files with 139 additions and 71 deletions
|
@ -1,10 +1,9 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
ca=100
|
ca=100
|
||||||
camax=0
|
camax=0
|
||||||
while [[ ${ca} -gt 0 ]]
|
while [[ ${ca} -gt 0 ]]; do
|
||||||
do
|
ca=$(sudo mariadb friendica -B -N -q -e "delete from workerqueue where regexp_replace(regexp_replace(\`parameter\`, '\\\[', ''), '\\\]', '') not in (select \`id\` from \`contact\` where \`id\` in (select \`contact-id\` from \`group_member\`) or \`id\` in (select \`cid\` from \`user-contact\`) or \`id\` in (select \`uid\` from \`user\`)) and \`command\` = \"UpdateContact\" limit ${ca}; select row_count();")
|
||||||
ca=$(sudo mariadb friendica -B -N -q -e "delete from workerqueue where regexp_replace(regexp_replace(\`parameter\`, '\\\[', ''), '\\\]', '') not in (select \`id\` from \`contact\` where \`id\` in (select \`contact-id\` from \`group_member\`)) and \`command\` = \"UpdateContact\" limit ${ca}; select row_count();")
|
camax=$((camax + ca))
|
||||||
camax=$(( camax + ca ))
|
|
||||||
printf "\rUpdateContact\t\t%s\r" "${camax}"
|
printf "\rUpdateContact\t\t%s\r" "${camax}"
|
||||||
done
|
done
|
||||||
printf "\rUpdateContact\t\t%s\n\r" "${camax}"
|
printf "\rUpdateContact\t\t%s\n\r" "${camax}"
|
||||||
|
@ -12,10 +11,9 @@ printf "\rUpdateContact\t\t%s\n\r" "${camax}"
|
||||||
|
|
||||||
cb=100
|
cb=100
|
||||||
cbmax=0
|
cbmax=0
|
||||||
while [[ ${cb} -gt 0 ]]
|
while [[ ${cb} -gt 0 ]]; do
|
||||||
do
|
cb=$(sudo mariadb friendica -B -N -q -e "delete from workerqueue where regexp_replace(regexp_replace(\`parameter\`, '\\\[', ''), '\\\]', '') not in (select \`id\` from \`contact\` where \`id\` in (select \`contact-id\` from \`group_member\`) or \`id\` in (select \`cid\` from \`user-contact\`) or \`id\` in (select \`uid\` from \`user\`)) and \`command\` = \"ContactDiscovery\" limit ${cb}; select row_count();")
|
||||||
cb=$(sudo mariadb friendica -B -N -q -e "delete from workerqueue where regexp_replace(regexp_replace(\`parameter\`, '\\\[', ''), '\\\]', '') not in (select \`id\` from \`contact\` where \`id\` in (select \`contact-id\` from \`group_member\`)) and \`command\` = \"ContactDiscovery\" limit ${cb}; select row_count();")
|
cbmax=$((cbmax + cb))
|
||||||
cbmax=$(( cbmax + cb ))
|
|
||||||
printf "\rContactDiscovery\t%s\r" "${cbmax}"
|
printf "\rContactDiscovery\t%s\r" "${cbmax}"
|
||||||
done
|
done
|
||||||
printf "\rContactDiscovery\t%s\n\r" "${cbmax}"
|
printf "\rContactDiscovery\t%s\n\r" "${cbmax}"
|
||||||
|
@ -23,10 +21,9 @@ printf "\rContactDiscovery\t%s\n\r" "${cbmax}"
|
||||||
|
|
||||||
cc=100
|
cc=100
|
||||||
ccmax=0
|
ccmax=0
|
||||||
while [[ ${cc} -gt 0 ]]
|
while [[ ${cc} -gt 0 ]]; do
|
||||||
do
|
cc=$(sudo mariadb friendica -B -N -q -e "delete from workerqueue where regexp_replace(substring_index(substring_index(\`parameter\`, '\\\"', -2), '\\\"', 1), '\\\\\\\\', '') not in (select \`url\` from \`contact\` where \`id\` in (select \`contact-id\` from \`group_member\`) or \`id\` in (select \`cid\` from \`user-contact\`) or \`id\` in (select \`uid\` from \`user\`)) and \`command\` = \"FetchFeaturedPosts\" limit ${cc}; select row_count();")
|
||||||
cc=$(sudo mariadb friendica -B -N -q -e "delete from workerqueue where regexp_replace(substring_index(substring_index(\`parameter\`, '\\\"', -2), '\\\"', 1), '\\\\\\\\', '') not in (select \`url\` from \`contact\` where \`id\` in (select \`contact-id\` from \`group_member\`)) and \`command\` = \"FetchFeaturedPosts\" limit ${cc}; select row_count();")
|
ccmax=$((ccmax + cc))
|
||||||
ccmax=$(( ccmax + cc ))
|
|
||||||
printf "\rFetchFeaturedPosts\t%s\r" "${ccmax}"
|
printf "\rFetchFeaturedPosts\t%s\r" "${ccmax}"
|
||||||
|
|
||||||
done
|
done
|
||||||
|
@ -35,10 +32,9 @@ printf "\rFetchFeaturedPosts\t%s\n\r" "${ccmax}"
|
||||||
|
|
||||||
cd=100
|
cd=100
|
||||||
cdmax=0
|
cdmax=0
|
||||||
while [[ ${cd} -gt 0 ]]
|
while [[ ${cd} -gt 0 ]]; do
|
||||||
do
|
cd=$(sudo mariadb friendica -B -N -q -e "delete from workerqueue where regexp_replace(substring_index(substring_index(\`parameter\`, '\\\"', -2), '\\\"', 1), '\\\\\\\\', '') not in (select \`url\` from \`contact\` where \`id\` in (select \`contact-id\` from \`group_member\`) or \`id\` in (select \`cid\` from \`user-contact\`) or \`id\` in (select \`uid\` from \`user\`)) and \`command\` = \"UpdateGServer\" limit ${cd}; select row_count();")
|
||||||
cd=$(sudo mariadb friendica -B -N -q -e "delete from workerqueue where regexp_replace(substring_index(substring_index(\`parameter\`, '\\\"', -2), '\\\"', 1), '\\\\\\\\', '') not in (select \`url\` from \`contact\` where \`id\` in (select \`contact-id\` from \`group_member\`)) and \`command\` = \"UpdateGServer\" limit ${cd}; select row_count();")
|
cdmax=$((cdmax + cd))
|
||||||
cdmax=$(( cdmax + cd ))
|
|
||||||
printf "\rUpdateGServer\t\t%s\r" "${cdmax}"
|
printf "\rUpdateGServer\t\t%s\r" "${cdmax}"
|
||||||
done
|
done
|
||||||
printf "\rUpdateGServer\t\t%s\n\r" "${cdmax}"
|
printf "\rUpdateGServer\t\t%s\n\r" "${cdmax}"
|
||||||
|
@ -46,12 +42,10 @@ printf "\rUpdateGServer\t\t%s\n\r" "${cdmax}"
|
||||||
|
|
||||||
ce=100
|
ce=100
|
||||||
cemax=0
|
cemax=0
|
||||||
while [[ ${ce} -gt 0 ]]
|
while [[ ${ce} -gt 0 ]]; do
|
||||||
do
|
|
||||||
ce=$(sudo mariadb friendica -B -N -q -e "delete from workerqueue where command=\"ProcessQueue\" and pid=0 and done=0 limit ${ce}; select row_count();")
|
ce=$(sudo mariadb friendica -B -N -q -e "delete from workerqueue where command=\"ProcessQueue\" and pid=0 and done=0 limit ${ce}; select row_count();")
|
||||||
cemax=$(( cemax + ce ))
|
cemax=$((cemax + ce))
|
||||||
printf "\rProcessQueue\t\t%s\r" "${cemax}"
|
printf "\rProcessQueue\t\t%s\r" "${cemax}"
|
||||||
done
|
done
|
||||||
printf "\rProcessQueue\t\t%s\n\r" "${cemax}"
|
printf "\rProcessQueue\t\t%s\n\r" "${cemax}"
|
||||||
#echo "ProcessQueue $cemax"
|
#echo "ProcessQueue $cemax"
|
||||||
|
|
||||||
|
|
|
@ -2,58 +2,132 @@
|
||||||
IFS="
|
IFS="
|
||||||
"
|
"
|
||||||
#media-optimize
|
#media-optimize
|
||||||
find . -type f -iname "*.jp*" -size +50k | (
|
while read -r p; do
|
||||||
while read p; do
|
nice -n 15 jpegoptim -m 76 "${p}" #&>/dev/null &
|
||||||
nice -n 15 jpegoptim -m 76 "${p}" &
|
if [[ $(jobs -r -p | wc -l) -ge $(getconf _NPROCESSORS_ONLN) ]]; then
|
||||||
if [[ $(jobs -r -p | wc -l) -ge $(getconf _NPROCESSORS_ONLN) ]]; then
|
wait -n
|
||||||
wait -n
|
fi
|
||||||
fi
|
done < <(find . -type f -iname "*.jp*" \( -size +50k -and -mtime -8 \))
|
||||||
done
|
wait
|
||||||
wait
|
while read -r q; do
|
||||||
)
|
nice -n 15 gifsicle --batch -O3 --lossy=80 --colors=255 "${q}" #&>/dev/null &
|
||||||
find . -type f -iname "*.gif" -size +500k | (
|
if [[ $(jobs -r -p | wc -l) -ge $(getconf _NPROCESSORS_ONLN) ]]; then
|
||||||
while read q; do
|
wait -n
|
||||||
nice -n 15 gifsicle --batch -O3 --lossy=80 --colors=255 "${q}" &
|
fi
|
||||||
if [[ $(jobs -r -p | wc -l) -ge $(getconf _NPROCESSORS_ONLN) ]]; then
|
done < <(find . -type f -iname "*.gif" \( -size +500k -and -mtime -8 \))
|
||||||
wait -n
|
wait
|
||||||
fi
|
while read -r p; do
|
||||||
done
|
(while [[ $(stat -c%s "${p}" || 0) -ge 512000 ]]; do
|
||||||
wait
|
frameamount=$(($(exiftool -b -FrameCount "${p}" || 1) - 1))
|
||||||
)
|
nice -n 15 gifsicle "${p}" $(seq -f "#%g" 0 2 "${frameamount}") -O3 --lossy=80 --colors=255 -o "${p}" #&>/dev/null
|
||||||
#Specific compression for large GIF files: halving the frame rate
|
done) &
|
||||||
find . -type f -size +500k -iname "*-320.gif" -or -iname "*-80.gif" -or -iname "*-48.gif" | (
|
if [[ $(jobs -r -p | wc -l) -ge $(getconf _NPROCESSORS_ONLN) ]]; then
|
||||||
while read p; do
|
wait -n
|
||||||
while [[ $(stat -c%s "${p}" || 0) -ge 512000 ]]; do
|
fi
|
||||||
frameamount=$(($(exiftool -b -FrameCount "${p}" || 1) - 1))
|
done < <(find . -type f -size +500k \( -iname "*-320.gif" -or -iname "*-80.gif" -or -iname "*-48.gif" \))
|
||||||
nice -n 15 gifsicle "${p}" $(seq -f "#%g" 0 2 "${frameamount}") -O3 --lossy=80 --colors=255 -o "${p}"
|
wait
|
||||||
done
|
while read -r r; do
|
||||||
done
|
nice -n 15 oxipng -o max "${r}" #&>/dev/null &
|
||||||
)
|
if [[ $(jobs -r -p | wc -l) -ge $(getconf _NPROCESSORS_ONLN) ]]; then
|
||||||
find . -type f -iname "*.png" -size +500k | (
|
wait -n
|
||||||
while read r; do
|
fi
|
||||||
nice -n 15 oxipng -o max "${r}" &
|
done < <(find . -type f -iname "*.png" -size +500k)
|
||||||
if [[ $(jobs -r -p | wc -l) -ge $(getconf _NPROCESSORS_ONLN) ]]; then
|
|
||||||
wait -n
|
wait
|
||||||
fi
|
|
||||||
done
|
|
||||||
wait
|
|
||||||
)
|
|
||||||
#compress-webp
|
#compress-webp
|
||||||
find . -type f -iname "*.webp" -size +50k | (
|
while read -r s; do
|
||||||
while read s; do
|
#If file is not animated
|
||||||
#If file is not animated
|
if ! grep -v -q -e "ANIM" -e "ANMF" "${s}"; then
|
||||||
if ! grep -v -q -e "ANIM" -e "ANMF" "${s}"; then
|
cwebp -mt -af -quiet "${s}" -o /tmp/"${s##.*\/}"_temp.webp #&>/dev/null
|
||||||
cwebp -mt -af -quiet "${s}" -o /tmp/"${s##.*\/}"_temp.webp
|
if [[ -f /tmp/"${s##.*\/}"_temp.webp ]]; then
|
||||||
if [[ -f /tmp/"${s##.*\/}"_temp.webp ]]; then
|
size_new=$(stat -c%s /tmp/"${s##.*\/}"_temp.webp || 0)
|
||||||
size_new=$(stat -c%s /tmp/"${s##.*\/}"_temp.webp || 0)
|
size_original=$(stat -c%s "${s}" || 0)
|
||||||
size_original=$(stat -c%s "${s}" || 0)
|
if [[ -n "${size_original}" && -n "${size_new}" && "${size_original}" -gt "${size_new}" ]]; then
|
||||||
if [[ "${size_original}" -gt "${size_new}" ]]; then
|
mv /tmp/"${s##.*\/}"_temp.webp "${s}"
|
||||||
mv /tmp/"${s##.*\/}"_temp.webp "${s}"
|
else
|
||||||
else
|
rm /tmp/"${s##.*\/}"_temp.webp
|
||||||
rm /tmp/"${s##.*\/}"_temp.webp
|
fi
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
done < <(find . -type f -iname "*.webp" \( -size +50k -and -mtime -8 \))
|
||||||
|
wait
|
||||||
|
while read -r i; do
|
||||||
|
if file -b "${i}" | grep -vq "PNG" | grep -vq "empty" | grep -vq "symbolic link" | grep -vq "directory" | grep -vq "text"; then
|
||||||
|
if file -b "${i}" | grep -q "JPEG"; then
|
||||||
|
mv "${i}" "${i%.*}".jpg
|
||||||
|
jpegoptim -m76 "${i%.*}".jpg #&>/dev/null
|
||||||
|
elif file "${i}" | grep -q "GIF"; then
|
||||||
|
mv "${i}" "${i%.*}".gif
|
||||||
|
gifsicle --batch -O3 --lossy=80 --colors=255 "${i%.*}".gif #&>/dev/null
|
||||||
|
elif file "${i}" | grep -q "Web/P"; then
|
||||||
|
mv "${i}" "${i%.*}".webp
|
||||||
|
#cwebp -mt -af -quiet $i
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
done < <(find . -iname "*.png" -mtime -8)
|
||||||
|
while read -r j; do
|
||||||
|
if file -b "${j}" | grep -v -q -e "JPEG" -e "empty" -e "symbolic link" -e "directory" -e "text"; then
|
||||||
|
if file -b "${j}" | grep -q "PNG"; then
|
||||||
|
mv "${j}" "${j%.*}".png
|
||||||
|
oxipng -o max "${j%.*}".png #&>/dev/null
|
||||||
|
elif file -b "${j}" | grep -q "GIF"; then
|
||||||
|
mv "${j}" "${j%.*}".gif
|
||||||
|
gifsicle --batch -O3 --lossy=80 --colors=255 "${j%.*}".gif #&>/dev/null
|
||||||
|
elif file -b "${j}" | grep -q "Web/P"; then
|
||||||
|
mv "${j}" "${j%.*}".webp
|
||||||
|
#If file is not animated
|
||||||
|
if ! grep -v -q -e "ANIM" -e "ANMF" "${s}"; then
|
||||||
|
cwebp -mt -af -quiet "${s}" -o /tmp/"${s##.*\/}"_temp.webp #&>/dev/null
|
||||||
|
if [[ -f /tmp/"${s##.*\/}"_temp.webp ]]; then
|
||||||
|
size_new=$(stat -c%s /tmp/"${s##.*\/}"_temp.webp || 0)
|
||||||
|
size_original=$(stat -c%s "${s}" || 0)
|
||||||
|
if [[ -n "${size_original}" && -n "${size_new}" && "${size_original}" -gt "${size_new}" ]]; then
|
||||||
|
mv /tmp/"${s##.*\/}"_temp.webp "${s}"
|
||||||
|
else
|
||||||
|
rm /tmp/"${s##.*\/}"_temp.webp
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
done
|
fi
|
||||||
wait
|
done < <(find . -mtime -8 \( -iname "*.jpg" -and -iname "*.jpeg" \))
|
||||||
)
|
while read -r k; do
|
||||||
|
if file -b "${k}" | grep -v -q -e "GIF" -e "empty" -e "symbolic link" -e "directory" -e "text"; then
|
||||||
|
if file -b "${k}" | grep -q "JPEG"; then
|
||||||
|
mv "${k}" "${k%.*}".jpg
|
||||||
|
jpegoptim -m76 "${k%.*}".jpg #&>/dev/null
|
||||||
|
elif file -b "${k}" | grep -q "PNG"; then
|
||||||
|
mv "${k}" "${k%.*}".png
|
||||||
|
oxipng -o max "${k%.*}".png #&>/dev/null
|
||||||
|
elif file -b "${k}" | grep -q "Web/P"; then
|
||||||
|
mv "${k}" "${k%.*}".webp
|
||||||
|
#If file is not animated
|
||||||
|
if ! grep -v -q -e "ANIM" -e "ANMF" "${s}"; then
|
||||||
|
cwebp -mt -af -quiet "${s}" -o /tmp/"${s##.*\/}"_temp.webp #&>/dev/null
|
||||||
|
if [[ -f /tmp/"${s##.*\/}"_temp.webp ]]; then
|
||||||
|
size_new=$(stat -c%s /tmp/"${s##.*\/}"_temp.webp || 0)
|
||||||
|
size_original=$(stat -c%s "${s}" || 0)
|
||||||
|
if [[ -n "${size_original}" && -n "${size_new}" && "${size_original}" -gt "${size_new}" ]]; then
|
||||||
|
mv /tmp/"${s##.*\/}"_temp.webp "${s}"
|
||||||
|
else
|
||||||
|
rm /tmp/"${s##.*\/}"_temp.webp
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
done < <(find . -iname "*.gif" -mtime -8)
|
||||||
|
while read -r l; do
|
||||||
|
if file -b "${l}" | grep -v -q -e "Web/P" -e "empty" -e "symbolic link" -e "directory" -e "text"; then
|
||||||
|
if file -b "${l}" | grep -q "JPEG"; then
|
||||||
|
mv "${l}" "${l%.*}".jpg
|
||||||
|
jpegoptim -m76 "${l%.*}".jpg #&>/dev/null
|
||||||
|
elif file -b "${l}" | grep -q "PNG"; then
|
||||||
|
mv "${l}" "${l%.*}".png
|
||||||
|
oxipng -o max "${l%.*}".png #&>/dev/null
|
||||||
|
elif file -b "${l}" | grep -q "GIF"; then
|
||||||
|
mv "${l}" "${l%.*}".gif
|
||||||
|
gifsicle --batch -O3 --lossy=80 --colors=255 "${l%.*}".gif #&>/dev/null
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
done < <(find . -iname "*.webp" -mtime -8)
|
||||||
|
|
Loading…
Add table
Reference in a new issue