* configure.pl checks version of Encode.pm. Reported by Chris Stone.
[BackupPC.git] / bin / BackupPC_trashClean
1 #!/bin/perl
2 #============================================================= -*-perl-*-
3 #
4 # BackupPC_trashClean: remove all the files in $TopDir/trash.
5 #
6 # DESCRIPTION
7 #   BackupPC_trashClean is started once by BackupPC.  Every 5 minutes
8 #   it wakes up and removes all the files or directories in $TopDir/trash.
9 #   
10 # AUTHOR
11 #   Craig Barratt  <cbarratt@users.sourceforge.net>
12 #
13 # COPYRIGHT
14 #   Copyright (C) 2001-2003  Craig Barratt
15 #
16 #   This program is free software; you can redistribute it and/or modify
17 #   it under the terms of the GNU General Public License as published by
18 #   the Free Software Foundation; either version 2 of the License, or
19 #   (at your option) any later version.
20 #
21 #   This program is distributed in the hope that it will be useful,
22 #   but WITHOUT ANY WARRANTY; without even the implied warranty of
23 #   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
24 #   GNU General Public License for more details.
25 #
26 #   You should have received a copy of the GNU General Public License
27 #   along with this program; if not, write to the Free Software
28 #   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
29 #
30 #========================================================================
31 #
32 # Version 3.0.0beta1, released 30 Jul 2006.
33 #
34 # See http://backuppc.sourceforge.net.
35 #
36 #========================================================================
37
38 use strict;
39 no  utf8;
40 use lib "/usr/local/BackupPC/lib";
41 use BackupPC::Lib;
42
43 die("BackupPC::Lib->new failed\n") if ( !(my $bpc = BackupPC::Lib->new) );
44 my $TopDir = $bpc->TopDir();
45 my $BinDir = $bpc->BinDir();
46 my %Conf   = $bpc->Conf();
47
48 $bpc->ChildInit();
49
50 ###########################################################################
51 # Empty trash every so often (eg: every 5 minutes)
52 ###########################################################################
53 while ( 1 ) {
54     print("processState running\n");
55     if ( $bpc->RmTreeTrashEmpty("$TopDir/trash") < 0 ) {
56         print("log BackupPC_trashClean failed to empty $TopDir/trash\n");
57     }
58     print("processState idle\n");
59     sleep($Conf{TrashCleanSleepSec} || 300);
60 }