Revision 7b642c49 daemons/ganeti-cleaner.in

b/daemons/ganeti-cleaner.in
1 1
#!/bin/bash
2 2
#
3 3

  
4
# Copyright (C) 2009, 2010 Google Inc.
4
# Copyright (C) 2009, 2010, 2011 Google Inc.
5 5
#
6 6
# This program is free software; you can redistribute it and/or modify
7 7
# it under the terms of the GNU General Public License as published by
......
20 20

  
21 21
set -e
22 22

  
23
in_cluster() {
24
  [[ -e $DATA_DIR/ssconf_master_node ]]
25
}
26

  
23 27
cleanup_master() {
24 28
  # Return if machine is not part of a cluster
25
  [[ -e $DATA_DIR/ssconf_master_node ]] || return 0
29
  in_cluster || return 0
26 30

  
27 31
  # Return if queue archive directory doesn't exist
28 32
  [[ -d $QUEUE_ARCHIVE_DIR ]] || return 0
......
45 49
  done
46 50
}
47 51

  
52
cleanup_watcher() {
53
  # Return if machine is not part of a cluster
54
  in_cluster || return 0
55

  
56
  # Remove old watcher files
57
  find $DATA_DIR -maxdepth 1 -type f -mtime +$REMOVE_AFTER \
58
    -name 'watcher.*-*-*-*.data' -print0 | \
59
  xargs -r0 rm -vf
60
}
61

  
48 62
# Overridden by unittest
49 63
: ${LOCALSTATEDIR:=@LOCALSTATEDIR@}
50 64
: ${CHECK_CERT_EXPIRED:=@PKGLIBDIR@/check-cert-expired}
......
77 91

  
78 92
cleanup_master
79 93
cleanup_node
94
cleanup_watcher
80 95

  
81 96
exit 0

Also available in: Unified diff