From 5e55104aa6e0a68916a30987dae6f5072c2284f1 Mon Sep 17 00:00:00 2001 From: Simon Fraser Date: Sat, 8 Aug 2015 22:10:32 +0100 Subject: [PATCH] Log rotation configuration file, and package.sh modifications to add it to deb and rpm --- etc/logrotate.d/telegraf | 10 ++++++++++ package.sh | 14 ++++++++++++++ 2 files changed, 24 insertions(+) create mode 100644 etc/logrotate.d/telegraf diff --git a/etc/logrotate.d/telegraf b/etc/logrotate.d/telegraf new file mode 100644 index 000000000..6a7dedfcf --- /dev/null +++ b/etc/logrotate.d/telegraf @@ -0,0 +1,10 @@ +/var/log/telegraf/telegraf.log +{ + rotate 6 + daily + missingok + notifempty + nocreate + compress +} + diff --git a/package.sh b/package.sh index c20e566cb..aece77cdb 100755 --- a/package.sh +++ b/package.sh @@ -35,8 +35,10 @@ AWS_FILE=~/aws.conf INSTALL_ROOT_DIR=/opt/telegraf TELEGRAF_LOG_DIR=/var/log/telegraf CONFIG_ROOT_DIR=/etc/opt/telegraf +LOGROTATE_DIR=/etc/logrotate.d SAMPLE_CONFIGURATION=etc/config.sample.toml +LOGROTATE_CONFIGURATION=etc/logrotate.d/telegraf INITD_SCRIPT=scripts/init.sh TMP_WORK_DIR=`mktemp -d` @@ -144,6 +146,12 @@ make_dir_tree() { echo "Failed to create configuration directory -- aborting." cleanup_exit 1 fi + mkdir -p $work_dir/$LOGROTATE_DIR + if [ $? -ne 0 ]; then + echo "Failed to create configuration directory -- aborting." + cleanup_exit 1 + fi + } @@ -251,6 +259,12 @@ if [ $? -ne 0 ]; then cleanup_exit 1 fi +cp $LOGROTATE_CONFIGURATION $TMP_WORK_DIR/$LOGROTATE_DIR/telegraf.conf +if [ $? -ne 0 ]; then + echo "Failed to copy $LOGROTATE_CONFIGURATION to packaging directory -- aborting." + cleanup_exit 1 +fi + generate_postinstall_script $VERSION ###########################################################################