scripts/73lab.sh
2014-09-13 21:23:13 +02:00

119 lines
4.1 KiB
Bash

#########################################
#!/bin/bash
# AjoutPingus 1.0
# 23/06/2002
#########################################
# vérifie si de nouveaux
# ouallpépères sont arrivés
# et dans ce cas les télécharge,
# et les converti dans les formats:
# - 1280x1204 png&jpeg
# - 1024x768 png&jpeg
# - 1024x768 png&jpeg
# - 800x600 png&jpeg
# et envoie un mail pour prévenir.
#########################################
# IMPORTANT: nécessite l'utilitaire
# ImageMagick http://www.imagemagick.org
#########################################
sujet="Ajout Pingus";
dest="n@tourmentine.com";
log="/tmp/ayo.log";
ok="";
if test -e $log;
then rm -f $log;
fi
wget -O /tmp/73lab.html http://www.73lab.com/index.php\?menu_item=1\&page=ALL\&curr_lang=0
for i in `cat /tmp/73lab.html | grep javascript | cut -d '&' -f 2 | tail +2 | cut -b 117- | cut -d '.' -f 1 | sed s/_1280_1024// | tail +1`
do
# image originale (1280x1024 png)
if test -e /var/ftp/pub/wallpaper/ayo73/png/1280x1024/$i\_1280\_1024.png;
then echo $ok;
else
wget -O /var/ftp/pub/wallpaper/ayo73/png/1280x1024/$i\_1280\_1024.png http://73lab.free.fr/distant_file/dessins/wallpaper/$i\_1280\_1024.png;
chown ftp:ftp /var/ftp/pub/wallpaper/ayo73/png/1280x1024/$i\_1280\_1024.png;
echo "var/ftp/pub/wallpaper/ayo73/png/1280x1024/$i-1280-1024.png">>$log;
fi
# 1024x768 png
if test -e /var/ftp/pub/wallpaper/ayo73/png/1024x768/$i\_1024\_768.png;
then echo $ok;
else
convert -enhance -geometry 1024x768! /var/ftp/pub/wallpaper/ayo73/png/1280x1024/$i\_1280\_1024.png /var/ftp/pub/wallpaper/ayo73/png/1024x768/$i\_1024\_768.png;
chown ftp:ftp /var/ftp/pub/wallpaper/ayo73/png/1024x768/$i\_1024\_768.png;
echo "/var/ftp/pub/wallpaper/ayo73/png/1280x1024/$i-1024-768.png">>$log;
fi
# 800x600 png
if test -e /var/ftp/pub/wallpaper/ayo73/png/800x600/$i\_800\_600.png;
then echo $ok;
else
convert -enhance -geometry 800x600! /var/ftp/pub/wallpaper/ayo73/png/1280x1024/$i\_1280\_1024.png /var/ftp/pub/wallpaper/ayo73/png/800x600/$i\_800\_600.png;
chown ftp:ftp /var/ftp/pub/wallpaper/ayo73/png/800x600/$i\_800\_600.png;
echo "/var/ftp/pub/wallpaper/ayo73/png/800x600/$i-800-600.png">>$log;
fi
# 1280x1024 jpeg
if test -e /var/ftp/pub/wallpaper/ayo73/jpeg/1280x1024/$i\_1280\_1024.jpg;
then echo $ok;
else
convert -enhance /var/ftp/pub/wallpaper/ayo73/png/1280x1024/$i\_1280\_1024.png /var/ftp/pub/wallpaper/ayo73/jpeg/1280x1024/$i\_1280\_1024.jpg;
chown ftp:ftp /var/ftp/pub/wallpaper/ayo73/jpeg/1280x1024/$i\_1280\_1024.jpg;
echo "/var/ftp/pub/wallpaper/ayo73/jpeg/1280x1024/$i-1280-1024.jpg">>$log;
fi
# 1024x768 jpeg
if test -e /var/ftp/pub/wallpaper/ayo73/jpeg/1024x768/$i\_1024\_768.jpg;
then echo $ok;
else
convert -enhance /var/ftp/pub/wallpaper/ayo73/png/1024x768/$i\_1024\_768.png /var/ftp/pub/wallpaper/ayo73/jpeg/1024x768/$i\_1024\_768.jpg;
chown ftp:ftp /var/ftp/pub/wallpaper/ayo73/jpeg/1024x768/$i\_1024\_768.jpg;
echo "/var/ftp/pub/wallpaper/ayo73/jpeg/1024x768/$i-1024-768.jpg">>$log;
fi
# ajoute ça à mes ouallepépères persos
if test -e /home/n/.wallpap/ayo73/$i\_1280\_1024.jpg;
then echo $ok;
else
cp /var/ftp/pub/wallpaper/ayo73/jpeg/1280x1024/$i\_1280\_1024.jpg /home/n/.wallpap/ayo73/;
chown n:n /home/n/.wallpap/ayo73/$i\_1280\_1024.jpg;
echo "/home/n/.wallpap/ayo73/$i-1280-1024.jpg">>$log;
fi
# 800x600 jpeg
if test -e /var/ftp/pub/wallpaper/ayo73/jpeg/800x600/$i\_800\_600.jpg;
then echo $ok;
else
convert -enhance /var/ftp/pub/wallpaper/ayo73/png/800x600/$i\_800\_600.png /var/ftp/pub/wallpaper/ayo73/jpeg/800x600/$i\_800\_600.jpg;
chown ftp:ftp /var/ftp/pub/wallpaper/ayo73/jpeg/800x600/$i\_800\_600.jpg;
echo "/var/ftp/pub/wallpaper/ayo73/jpeg/800x600/$i-800-600.jpg">>$log;
fi
# vignettes (153x122 jpeg)
if test -e /home/n/website/images/ayo73/$i\_1280\_1024.jpg;
then echo $ok;
else
convert -enhance -geometry 153x122! /var/ftp/pub/wallpaper/ayo73/png/1280x1024/$i\_1280\_1024.png /home/n/website/images/ayo73/$i\_1280\_1024.jpg;
chown n:n /home/n/website/images/ayo73/$i\_1280\_1024.jpg;
echo "/home/n/website/images/ayo73/$i-1280-1024.jpg">>$log;
fi
done
if test -e $log;
then sort $log | mail -s "$sujet" $dest
fi
rm -f /tmp/73lab.html;