RE: [netatalk-admins] Samba & Netatalk


Subject: RE: [netatalk-admins] Samba & Netatalk
From: Jonathan Newman (jnewman@mudpup.com)
Date: Fri Nov 19 1999 - 13:09:12 EST


>
> Maybe we should hack the ftp serivce, and force it to delete .AppleDoubles
> if it is exists?
>
> ayu

I ran across a Perl script that fixed this problem by deleting the files in the
.AppleDouble directories that had no corresponding match. Perhaps this Perl
script could be run as a cron to cleanup the issues you outlined.

Credit for this script goes to

Brian Wagner
brianw@IRISGROUP.COM

Usage:
perl AppleDoubleCheck /theDirToCheck
  will report any unattached resource files.

perl AppleDoubleCheck -d /theDirToCheck
  will delete unattached resource files.

Use -r to see unattached resource files recursively. Use -rd to delete
them.

===================================

#!/usr/bin/perl

if ($ARGV[0] =~ /^\-/)
{
        $source=$ARGV[1];
        if ($ARGV[0] eq '-d')
                { $remove=1;}
        elsif ($ARGV[0] eq '-r')
                { $recursive=1;}
        elsif (($ARGV[0] eq '-rd')||($ARGV[0] eq '-dr'))
                { $recursive=1;
                        $remove=1;}
        else {die("Bad switch\n");}
}else {
        $source=$ARGV[0];
}

&checkDir($source);

sub checkDir {
        my($sourceDir,$checkDir)=@_;
        my ($file,@chklist,@srclist);
        $checkDir=$sourceDir."/.AppleDouble";
        print "Checking $sourceDir\n";
        if (opendir(CHK,$checkDir))
        {
                @chklist=grep(!/^\./,readdir(CHK));
                closedir(CHK);

                foreach $file (@chklist)
                {
                        if (! -e "$sourceDir/$file")
                        {
                                if ($remove)
                                        {
                                                print "Removing:
.AppleDouble/$file\n";
                                                unlink("$checkDir/$file");
                                        }
                                else
                                        { print "Missing:$file\n";
                                        }
                        }
                }
        }
        if ($recursive) {
                opendir(SRC,$sourceDir);
                @srclist=grep(!/^\./,readdir(SRC)); #get dirs
                closedir(SRC);
                foreach $file (@srclist)
                {
                        if (-d "$sourceDir/$file")
                        {
                                &checkDir("$sourceDir/$file");
                        }
                }
        }
}



This archive was generated by hypermail 2b28 : Sat Dec 18 1999 - 16:17:27 EST