Koozali.org: home of the SME Server

Samba recycle-bin cleaner script bug

gundam

Samba recycle-bin cleaner script bug
« on: February 18, 2005, 05:14:38 PM »
Hi, i am a new user of sme server.
Recently i add the e-smith-samba-recycle-1.0-6.noarch.rpm from  the nightspirit contribs directory.
There is a little bug in /etc/cron.daily/samba-recyclebin.
This script manage in wrong way filenames with spaces and don't delete them.
I simply change the default value of bash var IFS and add a couple of quotes ad now it appear work ok.
Here there is a copy of my samba-recyclebin script.

bye
Max


#!/bin/bash
echo "+------------------------------------------------------------------------------+"
echo "|                           Samba recycle-bin cleaner                          |"
echo "+------------------------------------------------------------------------------+"
a=find /home/e-smith/files/users/*/home/.recycle/* -type f -mtime +7
if [ "$a" !=  "" ]
then
    printf "| %-76s |\n" "The following files were deleted:"
    IFS=$'\n'
    for file in $a
    do
        printf "| - %-74s |\n" "$file"
        rm -f "$file"
    done
else
    printf "| %-76s |\n" "There were no old files to delete."
fi
echo "+------------------------------------------------------------------------------+"

a=find /home/e-smith/files/users/*/home/.recycle/* -type d -empty
if [ "$a" != "" ]
then
    printf "| %-76s |\n" "The following directories were deleted:"
    IFS=$'\n'
    for folder in $a
    do
        printf "| - %-74s |\n" "$folder"
        rm -rf "$folder"
    done
else
    printf "| %-76s |\n" "There were no old directories to delete."
fi

echo "+------------------------------------------------------------------------------+"