summaryrefslogtreecommitdiffabout
authorSergey Poznyakoff <gray@gnu.org.ua>2014-09-01 11:23:13 (GMT)
committer Sergey Poznyakoff <gray@gnu.org.ua>2014-09-01 11:23:13 (GMT)
commitaa48c0113be59350159788f9efd43d8736e87dcb (patch) (side-by-side diff)
tree05f6ac39705efbf5acdd86e1629749c80f402409
parent1c1930ac5260847b9b6e63caf3ba844be8a7d41f (diff)
downloadbeam-aa48c0113be59350159788f9efd43d8736e87dcb.tar.gz
beam-aa48c0113be59350159788f9efd43d8736e87dcb.tar.bz2
Clean up remote files
* cleaner.in: Detect if the files are remote, use beam_exec to remove them.
Diffstat (more/less context) (ignore whitespace changes)
-rwxr-xr-xcleaner.in30
1 files changed, 22 insertions, 8 deletions
diff --git a/cleaner.in b/cleaner.in
index a35b605..1db87c1 100755
--- a/cleaner.in
+++ b/cleaner.in
@@ -67,6 +67,15 @@ case $# in
exit 1;;
esac
+remote=${dir%%:*}
+if [ "$remote" != "$dir" ]; then
+ beam_rsh="${backup_rsh:-ssh} $remote"
+ localdir=${dir#*:}
+else
+ beam_rsh=
+ localdir=$dir
+fi
+
thisweek=$(date +%U)
# Warning: do not use shell arithmetic expansions on week numbers,
@@ -81,23 +90,28 @@ fi
$verbose \# removing from $dir files ending in $suffix and older than week $lastweek
if [ -z "$suffix" ]; then
- find $dir -maxdepth 1 -type f -printf '%f\n'
+ beam_exec find $localdir -maxdepth 1 -type f -printf '%f>n'
else
- find $dir -maxdepth 1 -type f -name "*$suffix" -printf '%f\n'
+ beam_exec find $localdir -maxdepth 1 -type f -name "*$suffix" -printf '%f>n'
fi |
while read name
do
- $verbose \# considering $name
week=$(expr "$name" : '.*-\([0-9][0-9]*\)-[0-9][0-9]*-[0-9][0-9]*.*$')
if [ $thisweek -ge $week ]; then
if [ $(expr $thisweek - $week) -gt $retainweeks ]; then
- $verbose \# removing $name
- $dry_run rm $dir/$name
+ echo $localdir/$name
fi
else
if [ $(expr $thisweek + 54 - $week) -gt $retainweeks ]; then
- $verbose \# removing $name
- $dry_run rm $dir/$name
+ echo $localdir/$name
fi
fi
- done
+ done |
+ if [ -z "$dry_run" ]; then
+ beam_exec xargs --no-run-if-empty rm
+ else
+ while read name
+ do
+ echo \# rm $name
+ done
+ fi

Return to:

Send suggestions and report system problems to the System administrator.