root / daemons / ganeti-cleaner.in @ 4776e022
History | View | Annotate | Download (1.2 kB)
1 | fc3fd894 | Michael Hanselmann | #!/bin/bash |
---|---|---|---|
2 | fc3fd894 | Michael Hanselmann | # |
3 | fc3fd894 | Michael Hanselmann | |
4 | fc3fd894 | Michael Hanselmann | # Copyright (C) 2009 Google Inc. |
5 | fc3fd894 | Michael Hanselmann | # |
6 | fc3fd894 | Michael Hanselmann | # This program is free software; you can redistribute it and/or modify |
7 | fc3fd894 | Michael Hanselmann | # it under the terms of the GNU General Public License as published by |
8 | fc3fd894 | Michael Hanselmann | # the Free Software Foundation; either version 2 of the License, or |
9 | fc3fd894 | Michael Hanselmann | # (at your option) any later version. |
10 | fc3fd894 | Michael Hanselmann | # |
11 | fc3fd894 | Michael Hanselmann | # This program is distributed in the hope that it will be useful, but |
12 | fc3fd894 | Michael Hanselmann | # WITHOUT ANY WARRANTY; without even the implied warranty of |
13 | fc3fd894 | Michael Hanselmann | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
14 | fc3fd894 | Michael Hanselmann | # General Public License for more details. |
15 | fc3fd894 | Michael Hanselmann | # |
16 | fc3fd894 | Michael Hanselmann | # You should have received a copy of the GNU General Public License |
17 | fc3fd894 | Michael Hanselmann | # along with this program; if not, write to the Free Software |
18 | fc3fd894 | Michael Hanselmann | # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA |
19 | fc3fd894 | Michael Hanselmann | # 02110-1301, USA. |
20 | fc3fd894 | Michael Hanselmann | |
21 | fc3fd894 | Michael Hanselmann | set -e |
22 | fc3fd894 | Michael Hanselmann | |
23 | fc3fd894 | Michael Hanselmann | DATA_DIR=@LOCALSTATEDIR@/lib/ganeti |
24 | fc3fd894 | Michael Hanselmann | QUEUE_ARCHIVE_DIR=$DATA_DIR/queue/archive |
25 | fc3fd894 | Michael Hanselmann | |
26 | fc3fd894 | Michael Hanselmann | # Define how many days archived jobs should be left alone |
27 | fc3fd894 | Michael Hanselmann | REMOVE_AFTER=21 |
28 | fc3fd894 | Michael Hanselmann | |
29 | fc3fd894 | Michael Hanselmann | # Exit if machine is not part of a cluster |
30 | fc3fd894 | Michael Hanselmann | [[ -e $DATA_DIR/ssconf_master_node ]] || echo 0 |
31 | fc3fd894 | Michael Hanselmann | |
32 | fc3fd894 | Michael Hanselmann | # Exit if queue archive directory doesn't exist |
33 | fc3fd894 | Michael Hanselmann | [[ -d $QUEUE_ARCHIVE_DIR ]] || exit 0 |
34 | fc3fd894 | Michael Hanselmann | |
35 | fc3fd894 | Michael Hanselmann | # Remove old jobs |
36 | fc3fd894 | Michael Hanselmann | find $QUEUE_ARCHIVE_DIR -mindepth 2 -type f -mtime +$REMOVE_AFTER -print0 | \ |
37 | fc3fd894 | Michael Hanselmann | xargs -r0 rm -f |
38 | fc3fd894 | Michael Hanselmann | |
39 | fc3fd894 | Michael Hanselmann | exit 0 |