Set log directory attributes in rpm spec (#5716)

This commit is contained in:
Lorenzo Affetti 2019-04-16 01:07:47 +02:00 committed by Daniel Nelson
parent 5bf793bb94
commit 37441e9eb1
2 changed files with 12 additions and 4 deletions

View File

@ -18,6 +18,8 @@ import argparse
# Packaging variables
PACKAGE_NAME = "telegraf"
USER = "telegraf"
GROUP = "telegraf"
INSTALL_ROOT_DIR = "/usr/bin"
LOG_DIR = "/var/log/telegraf"
SCRIPT_DIR = "/usr/lib/telegraf/scripts"
@ -66,6 +68,7 @@ fpm_common_args = "-f -s dir --log error \
--before-install {} \
--after-remove {} \
--before-remove {} \
--rpm-attr 755,{},{}:{} \
--description \"{}\"".format(
VENDOR,
PACKAGE_URL,
@ -77,6 +80,7 @@ fpm_common_args = "-f -s dir --log error \
PREINST_SCRIPT,
POSTREMOVE_SCRIPT,
PREREMOVE_SCRIPT,
USER, GROUP, LOG_DIR,
DESCRIPTION)
targets = {

View File

@ -32,10 +32,6 @@ if ! id telegraf &>/dev/null; then
useradd -r -M telegraf -s /bin/false -d /etc/telegraf -g telegraf
fi
test -d $LOG_DIR || mkdir -p $LOG_DIR
chown -R -L telegraf:telegraf $LOG_DIR
chmod 755 $LOG_DIR
# Remove legacy symlink, if it exists
if [[ -L /etc/init.d/telegraf ]]; then
rm -f /etc/init.d/telegraf
@ -72,6 +68,14 @@ if [[ -f /etc/redhat-release ]] || [[ -f /etc/SuSE-release ]]; then
fi
elif [[ -f /etc/debian_version ]]; then
# Debian/Ubuntu logic
# Ownership for RH-based platforms is set in build.py via the `rmp-attr` option.
# We perform ownership change only for Debian-based systems.
# Moving these lines out of this if statement would make `rmp -V` fail after installation.
test -d $LOG_DIR || mkdir -p $LOG_DIR
chown -R -L telegraf:telegraf $LOG_DIR
chmod 755 $LOG_DIR
if [[ "$(readlink /proc/1/exe)" == */systemd ]]; then
install_systemd /lib/systemd/system/telegraf.service
deb-systemd-invoke restart telegraf.service || echo "WARNING: systemd not running."