-
Notifications
You must be signed in to change notification settings - Fork 238
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Loading status checks…
Merge pull request #2873 from jcharaoui/prune-reports
(maint) Add puppetserver prune subcommand
Showing
1 changed file
with
30 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,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 |