File: prune.erb

package info (click to toggle)
puppetserver 8.7.0-6
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 5,476 kB
  • sloc: ruby: 5,764; sh: 997; java: 221; xml: 111; makefile: 94
file content (30 lines) | stat: -rw-r--r-- 710 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
#!/usr/bin/env bash

usage() {
    echo "Prune contents of report and bucket directories."
    echo
    echo "Usage: puppetserver prune <reportdir|bucketdir> [<ttl>]"
    echo "  bucketdir|reportdir  work on either bucketdir or reportdir"
    echo "  <ttl>                delete data older than this amount of time (default: 14d)"
}

prune() {
    DIR="$1"
    AGE=${2:-14d}
    puppet apply --no-report --log_level=warning -e "tidy { \$settings::${DIR}: age=>'${AGE}', recurse=>true, rmdirs=>true }"
}

case $1 in
    -h|--help)
        usage
        exit 0
    ;;
    bucketdir|reportdir)
        prune "$1" "$2"
    ;;
    *)
        echo "Error: unknown argument."
        usage
        exit 1
    ;;
esac