update script and add cronjob
This commit is contained in:
parent
1fa54b67b7
commit
8cc9749423
20
cron/optimize-cron.sh
Normal file
20
cron/optimize-cron.sh
Normal file
|
@ -0,0 +1,20 @@
|
||||||
|
input="sites.csv"
|
||||||
|
while IFS='|' read -r f1 f2
|
||||||
|
do
|
||||||
|
imagepath="$f2"
|
||||||
|
# optimize jpg images created in the last 24 hours
|
||||||
|
find $imagepath -iname "*.jp*" -ctime 0 -print0 | xargs -0 jpegoptim --quiet --strip-all -m76
|
||||||
|
# optimize png images created in the last 24 hours
|
||||||
|
find $imagepath -iname '*.png' -ctime 0 -print0 | xargs -0 optipng -o7 -quiet -preserve
|
||||||
|
# convert png to webp
|
||||||
|
find $imagepath -iname "*.png" -ctime 0 -print0 | xargs -0 -I {} \
|
||||||
|
bash -c 'webp_version="$0".webp
|
||||||
|
if [ ! -f "$webp_version" ]; then
|
||||||
|
{ cwebp -quiet -lossless {} -o {}.webp; }
|
||||||
|
fi'
|
||||||
|
find $imagepath -iname "*.jp*" -ctime 0 -print0 | xargs -0 -I {} \
|
||||||
|
bash -c 'webp_version="$0".webp
|
||||||
|
if [ ! -f "$webp_version" ]; then
|
||||||
|
{ cwebp -quiet -lossless {} -o {}.webp; }
|
||||||
|
fi'
|
||||||
|
done < "$input"
|
2
cron/sites.csv
Normal file
2
cron/sites.csv
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
1|/var/www/yoursite.tld/htdocs/wp-content/uploads
|
||||||
|
2|/var/www/yourothersite.tld/htdocs/wp-content/uploads
|
|
13
install-optipng.sh
Normal file
13
install-optipng.sh
Normal file
|
@ -0,0 +1,13 @@
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
sudo apt-get install build-essential libpng-dev -y
|
||||||
|
|
||||||
|
cd /usr/local/src
|
||||||
|
|
||||||
|
OPTIPNGLATEST=$(wget http://optipng.sourceforge.net/ -O - | grep tar.gz | awk -F "[\"]" '{print $4}')
|
||||||
|
wget $OPTIPNGLATEST -O optipng.tar.gz
|
||||||
|
tar -xf optipng.tar.gz
|
||||||
|
cd optipng-*
|
||||||
|
./configure --prefix=/usr
|
||||||
|
make -j "$(nproc)"
|
||||||
|
sudo make install
|
|
@ -46,8 +46,7 @@ find $imagepath -iname '*.png' -print0 | xargs -0 optipng -o7 -quiet -preserve
|
||||||
# convert png to webp
|
# convert png to webp
|
||||||
webpconvert() {
|
webpconvert() {
|
||||||
find $imagepath -iname "*.png" -print0 | xargs -0 -I {} \
|
find $imagepath -iname "*.png" -print0 | xargs -0 -I {} \
|
||||||
bash -c '
|
bash -c 'webp_version="$0".webp
|
||||||
webp_version="$0".webp
|
|
||||||
if [ ! -f "$webp_version" ]; then
|
if [ ! -f "$webp_version" ]; then
|
||||||
{ cwebp -quiet -lossless {} -o {}.webp; }
|
{ cwebp -quiet -lossless {} -o {}.webp; }
|
||||||
fi'
|
fi'
|
||||||
|
@ -57,9 +56,7 @@ fi'
|
||||||
|
|
||||||
# convert jpg to webp
|
# convert jpg to webp
|
||||||
find $imagepath -iname "*.jp*" -print0 | xargs -0 -I {} \
|
find $imagepath -iname "*.jp*" -print0 | xargs -0 -I {} \
|
||||||
bash -c '
|
bash -c 'webp_version="$0".webp
|
||||||
webp_version="$0".webp
|
|
||||||
|
|
||||||
if [ ! -f "$webp_version" ]; then
|
if [ ! -f "$webp_version" ]; then
|
||||||
{ cwebp -quiet -lossless {} -o {}.webp; }
|
{ cwebp -quiet -lossless {} -o {}.webp; }
|
||||||
fi'
|
fi'
|
||||||
|
|
Loading…
Reference in New Issue
Block a user