Set log directory attributes in rpm spec (#5716)
This commit is contained in:
parent
5bf793bb94
commit
37441e9eb1
|
@ -18,6 +18,8 @@ import argparse
|
||||||
|
|
||||||
# Packaging variables
|
# Packaging variables
|
||||||
PACKAGE_NAME = "telegraf"
|
PACKAGE_NAME = "telegraf"
|
||||||
|
USER = "telegraf"
|
||||||
|
GROUP = "telegraf"
|
||||||
INSTALL_ROOT_DIR = "/usr/bin"
|
INSTALL_ROOT_DIR = "/usr/bin"
|
||||||
LOG_DIR = "/var/log/telegraf"
|
LOG_DIR = "/var/log/telegraf"
|
||||||
SCRIPT_DIR = "/usr/lib/telegraf/scripts"
|
SCRIPT_DIR = "/usr/lib/telegraf/scripts"
|
||||||
|
@ -66,6 +68,7 @@ fpm_common_args = "-f -s dir --log error \
|
||||||
--before-install {} \
|
--before-install {} \
|
||||||
--after-remove {} \
|
--after-remove {} \
|
||||||
--before-remove {} \
|
--before-remove {} \
|
||||||
|
--rpm-attr 755,{},{}:{} \
|
||||||
--description \"{}\"".format(
|
--description \"{}\"".format(
|
||||||
VENDOR,
|
VENDOR,
|
||||||
PACKAGE_URL,
|
PACKAGE_URL,
|
||||||
|
@ -77,6 +80,7 @@ fpm_common_args = "-f -s dir --log error \
|
||||||
PREINST_SCRIPT,
|
PREINST_SCRIPT,
|
||||||
POSTREMOVE_SCRIPT,
|
POSTREMOVE_SCRIPT,
|
||||||
PREREMOVE_SCRIPT,
|
PREREMOVE_SCRIPT,
|
||||||
|
USER, GROUP, LOG_DIR,
|
||||||
DESCRIPTION)
|
DESCRIPTION)
|
||||||
|
|
||||||
targets = {
|
targets = {
|
||||||
|
|
|
@ -32,10 +32,6 @@ if ! id telegraf &>/dev/null; then
|
||||||
useradd -r -M telegraf -s /bin/false -d /etc/telegraf -g telegraf
|
useradd -r -M telegraf -s /bin/false -d /etc/telegraf -g telegraf
|
||||||
fi
|
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
|
# Remove legacy symlink, if it exists
|
||||||
if [[ -L /etc/init.d/telegraf ]]; then
|
if [[ -L /etc/init.d/telegraf ]]; then
|
||||||
rm -f /etc/init.d/telegraf
|
rm -f /etc/init.d/telegraf
|
||||||
|
@ -72,6 +68,14 @@ if [[ -f /etc/redhat-release ]] || [[ -f /etc/SuSE-release ]]; then
|
||||||
fi
|
fi
|
||||||
elif [[ -f /etc/debian_version ]]; then
|
elif [[ -f /etc/debian_version ]]; then
|
||||||
# Debian/Ubuntu logic
|
# 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
|
if [[ "$(readlink /proc/1/exe)" == */systemd ]]; then
|
||||||
install_systemd /lib/systemd/system/telegraf.service
|
install_systemd /lib/systemd/system/telegraf.service
|
||||||
deb-systemd-invoke restart telegraf.service || echo "WARNING: systemd not running."
|
deb-systemd-invoke restart telegraf.service || echo "WARNING: systemd not running."
|
||||||
|
|
Loading…
Reference in New Issue