kernel - TMPFS - Bug fixing pass - fsync, vnode locks
[dragonfly.git] / bin / cpdup / scripts / do_cleanup
blobd8cf4ccad876776ec7aa24dfddb5f43bbd5f3ba9
1 #!/bin/csh
3 # $DragonFly: src/bin/cpdup/scripts/do_cleanup,v 1.1 2006/09/16 21:57:10 dillon Exp $
5 source params
7 if ( "$argv" == "" ) then
8 echo "./do_cleanup percentage"
9 exit 1
10 endif
12 set full = $argv[1]
14 while (1)
15 set dcap = `df -i $cleaning_path | tail -1 | awk '{ print $5; }' | sed -e 's/%//'`
16 set icap = `df -i $cleaning_path | tail -1 | awk '{ print $8; }' | sed -e 's/%//'`
17 echo "space $dcap/$full inodes $icap/$full"
19 if ( $dcap < $full && $icap < $full ) then
20 break
21 endif
23 foreach i ( ${backup_nfs}/* )
24 set host = ${i:t}
25 if ( ! -d $backup_nfs/$host ) then
26 continue
27 endif
28 set curbackup = `readlink $cleaning_path/mirrors/$host`
29 foreach item ( `ls -1da $cleaning_path/mirrors/$host.*` )
30 if ( ! -d $item ) then
31 continue
32 endif
33 if ( "${item:t}" == "$curbackup" ) then
34 continue
35 endif
36 echo "Removing $item"
37 # for safety, use a full path and do not rely on item's path
39 rm -rf $cleaning_path/mirrors/${item:t}
40 break
41 end
42 end
44 # let the fs catch up and update the df info
46 sync
47 sync
48 foreach benice ( 1 2 3 4 5 )
49 sync
50 sleep 5
51 end
52 sync
53 sync
54 end