s script installs a cleaner script which sweeps# > user tmp files# > thumbnails# The cleaner script is launched when the computer is turned off or rebooted. ############################################################ This program is free software; you can redistribute it and/or modify# it under the terms of the GNU General Public License as published by# the Free Software Foundation; either version 2 of the License, or# (at your option) any later version.## This program is distributed in the hope that it will be useful,# but WITHOUT ANY WARRANTY; without even the implied warranty of# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the# GNU General Public License for more details.## You should have received a copy of the GNU General Public License# along with this program; if not, write to the Free Software# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA############################################################## Written by Spip <unpeudescience at gmail.com># Improved by Ptyxs <onyxs at free.fr>############################################################## messages & comments are only written in frenchinit='/etc/init.d'RC0='/etc/rc0.d'RC6='/etc/rc6.d'# verification des droits administrateursif [ "$UID" != "0" ]; then echo 'ERREUR 101 : ce script doit être lancé en tant que superutilisateur (root)'exit 101fi############################################################ création du script de nettoyage###########################################################if ! [ -e $init/tmp.nettoyage ]then echo -e "Ecriture du script $init/tmp.nettoyage\n" echo "#! /bin/bash" > $init/tmp.nettoyage echo "/usr/sbin/tmpwatch -a --nosymlinks 3d /home/*/tmp" >> $init/tmp.nettoyage echo "find /home/*/.thumbnails -type f -iname '*.png' | xargs rm -f" >> $init/tmp.nettoyageelse echo 'ERREUR 102 : le programme semble être déjà installé ! ' echo "Si vous souhaitez réinstaller le script, effacez d'abord sous root les fichiers :" echo "/etc/init.d/tmp.nettoyage" echo "/etc/rc0.d/S00tmp.nettoyage" echo "/etc/rc6.d/S00tmp.nettoyage" exit 102fichmod 700 $init/tmp.nettoyage############################################################ décalage des numeros des scripts de rc0 et rc6############################################################ existence des répertoires#if ! [ -d $RC0 ] then rm -f $init/tmp.nettoyage echo "ERREUR 103 : le répertoire $RC0 n existe pas" exit 103fiif ! [ -d $RC6 ]then rm -f $init/tmp.nettoyage echo "ERREUR 103 : le répertoire $RC6 n existe pas" exit 103fi# decalage for RC in $RC0 $RC6 do cd $RC if [ $(ls | grep '^S00') ] #s'il existe un lien S00 on décale then if [ $(ls | grep '^S99') ] #à moins qu'il n'y ait aussi un S99 then rm -f $init/tmp.nettoyage echo "ERREUR 104 : Dans $RC, un script possède la priorité 99, veuillez faire une installation manuelle." exit 104 fi echo -e "Décalage des scripts de $RC \n " fichiers=$(ls S*) for line in $fichiers do #on recupere le nombre sans le premier 0 s'il y en a un nb=$(echo $line | sed -e "s/\([a-z,.,_,-]\)//g") nb=$(echo $nb | sed -e 's/^0//') #on incrémente nb=$(($nb+1)) if [ $nb -lt 10 ] then newline=$(echo $line | sed -e "s/\([0][0-9]\)/0$nb/") else newline=$(echo $line | sed -e "s/\([0-9][0-9]\)/$nb/") fi mv $line $newline #on change le numero du lien done fi echo -e "Création du lien symbolique de $init vers $RC \n" ln -sv $init/tmp.nettoyage $RC/S00tmp.nettoyage done echo -e '\n Félicitations, le script est installé !'exit 0