2016-01-08 15:47:09 +00:00
|
|
|
#!/bin/bash
|
|
|
|
|
2019-04-30 18:04:45 +00:00
|
|
|
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
|
|
|
|
|
2017-04-20 18:19:33 +00:00
|
|
|
if [[ -d /etc/opt/telegraf ]]; then
|
2016-01-08 15:47:09 +00:00
|
|
|
# Legacy configuration found
|
|
|
|
if [[ ! -d /etc/telegraf ]]; then
|
2017-04-20 18:19:33 +00:00
|
|
|
# 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
|
2016-01-08 15:47:09 +00:00
|
|
|
|
2017-04-20 18:19:33 +00:00
|
|
|
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
|
2016-01-08 15:47:09 +00:00
|
|
|
fi
|
|
|
|
fi
|