1
0
Fork 0

Adding upstream version 1.34.4.

Signed-off-by: Daniel Baumann <daniel@debian.org>
This commit is contained in:
Daniel Baumann 2025-05-24 07:26:29 +02:00
parent e393c3af3f
commit 4978089aab
Signed by: daniel
GPG key ID: FBB4F0E80A80222F
4963 changed files with 677545 additions and 0 deletions

View file

@ -0,0 +1,50 @@
#!/bin/bash
# Remove legacy symlink, if it exists
if [[ -L /etc/init.d/telegraf ]]; then
rm -f /etc/init.d/telegraf
fi
# Add defaults file, if it doesn't exist
if [[ ! -f /etc/default/telegraf ]]; then
touch /etc/default/telegraf
fi
# Add .d configuration directory
if [[ ! -d /etc/telegraf/telegraf.d ]]; then
mkdir -p /etc/telegraf/telegraf.d
fi
# If 'telegraf.conf' is not present use package's sample (fresh install)
if [[ ! -f /etc/telegraf/telegraf.conf ]] && [[ -f /etc/telegraf/telegraf.conf.sample ]]; then
cp /etc/telegraf/telegraf.conf.sample /etc/telegraf/telegraf.conf
fi
# Set up log directories
LOG_DIR=/var/log/telegraf
mkdir -p $LOG_DIR
chown -R -L telegraf:telegraf $LOG_DIR
chmod 755 $LOG_DIR
STATE_DIR=/var/lib/telegraf
test -d "$STATE_DIR" || {
mkdir -p "$STATE_DIR"
chmod 770 "$STATE_DIR"
chown root:telegraf "$STATE_DIR"
}
STATE_FILE="$STATE_DIR/statefile"
test -f "$STATE_FILE" || {
touch "$STATE_FILE"
echo {} > "$STATE_FILE"
chown root:telegraf "$STATE_FILE"
chmod 660 "$STATE_FILE"
}
# Set up systemd service - check if the systemd directory exists per:
# https://www.freedesktop.org/software/systemd/man/sd_booted.html
if [[ -d /run/systemd/system ]]; then
cp -f /usr/lib/telegraf/scripts/telegraf.service /usr/lib/systemd/system/telegraf.service
systemctl enable telegraf
systemctl daemon-reload
fi

View file

@ -0,0 +1,19 @@
#!/bin/bash
# Telegraf is no longer installed, remove from systemd
if [[ "$1" = "0" ]]; then
rm -f /etc/default/telegraf
if [[ -d /run/systemd/system ]]; then
systemctl disable telegraf
rm -f /usr/lib/systemd/system/telegraf.service
systemctl daemon-reload
fi
fi
# Telegraf upgrade, restart service
if [[ $1 -ge 1 ]]; then
if [[ -d /run/systemd/system ]]; then
systemctl try-restart telegraf.service >/dev/null 2>&1 || :
fi
fi

View file

@ -0,0 +1,24 @@
#!/bin/bash
if ! grep "^telegraf:" /etc/group &>/dev/null; then
groupadd -r telegraf
fi
if ! id telegraf &>/dev/null; then
useradd -r -M telegraf -s /bin/false -d /etc/telegraf -g telegraf
fi
if [[ -d /etc/opt/telegraf ]]; then
# Legacy configuration found
if [[ ! -d /etc/telegraf ]]; then
# New configuration does not exist, move legacy configuration to new location
echo -e "Please note, Telegraf's configuration is now located at '/etc/telegraf' (previously '/etc/opt/telegraf')."
mv -vn /etc/opt/telegraf /etc/telegraf
if [[ -f /etc/telegraf/telegraf.conf ]]; then
backup_name="telegraf.conf.$(date +%s).backup"
echo "A backup of your current configuration can be found at: /etc/telegraf/${backup_name}"
cp -a "/etc/telegraf/telegraf.conf" "/etc/telegraf/${backup_name}"
fi
fi
fi