chore: Do not start service on deb install (#12405)

This commit is contained in:
Joshua Powers 2022-12-16 02:32:21 -07:00 committed by GitHub
parent d9820bfd7b
commit 02699341e7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 9 deletions

View File

@ -1,9 +1,7 @@
#!/bin/bash
BIN_DIR=/usr/bin
LOG_DIR=/var/log/telegraf
SCRIPT_DIR=/usr/lib/telegraf/scripts
LOGROTATE_DIR=/etc/logrotate.d
function install_init {
cp -f $SCRIPT_DIR/init.sh /etc/init.d/telegraf
@ -11,6 +9,7 @@ function install_init {
}
function install_systemd {
#shellcheck disable=SC2086
cp -f $SCRIPT_DIR/telegraf.service $1
systemctl enable telegraf || true
systemctl daemon-reload || true
@ -52,9 +51,10 @@ 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."
if [ -d /run/systemd/system ]; then
install_systemd /lib/systemd/system/telegraf.service
# if and only if the service was already running then restart
deb-systemd-invoke try-restart telegraf.service >/dev/null || true
else
# Assuming SysVinit
install_init

View File

@ -1,9 +1,9 @@
#!/bin/bash
BIN_DIR=/usr/bin
if [[ "$(readlink /proc/1/exe)" == */systemd ]]; then
deb-systemd-invoke stop telegraf.service
if [ -d /run/systemd/system ]; then
if [ "$1" = remove ]; then
deb-systemd-invoke stop telegraf.service
fi
else
# Assuming sysv
invoke-rc.d telegraf stop