chore: Do not start service on deb install (#12405)
This commit is contained in:
parent
d9820bfd7b
commit
02699341e7
|
|
@ -1,9 +1,7 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
BIN_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
|
||||||
LOGROTATE_DIR=/etc/logrotate.d
|
|
||||||
|
|
||||||
function install_init {
|
function install_init {
|
||||||
cp -f $SCRIPT_DIR/init.sh /etc/init.d/telegraf
|
cp -f $SCRIPT_DIR/init.sh /etc/init.d/telegraf
|
||||||
|
|
@ -11,6 +9,7 @@ function install_init {
|
||||||
}
|
}
|
||||||
|
|
||||||
function install_systemd {
|
function install_systemd {
|
||||||
|
#shellcheck disable=SC2086
|
||||||
cp -f $SCRIPT_DIR/telegraf.service $1
|
cp -f $SCRIPT_DIR/telegraf.service $1
|
||||||
systemctl enable telegraf || true
|
systemctl enable telegraf || true
|
||||||
systemctl daemon-reload || true
|
systemctl daemon-reload || true
|
||||||
|
|
@ -52,9 +51,10 @@ test -d $LOG_DIR || mkdir -p $LOG_DIR
|
||||||
chown -R -L telegraf:telegraf $LOG_DIR
|
chown -R -L telegraf:telegraf $LOG_DIR
|
||||||
chmod 755 $LOG_DIR
|
chmod 755 $LOG_DIR
|
||||||
|
|
||||||
if [[ "$(readlink /proc/1/exe)" == */systemd ]]; then
|
if [ -d /run/systemd/system ]; 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."
|
# if and only if the service was already running then restart
|
||||||
|
deb-systemd-invoke try-restart telegraf.service >/dev/null || true
|
||||||
else
|
else
|
||||||
# Assuming SysVinit
|
# Assuming SysVinit
|
||||||
install_init
|
install_init
|
||||||
|
|
|
||||||
|
|
@ -1,9 +1,9 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
BIN_DIR=/usr/bin
|
if [ -d /run/systemd/system ]; then
|
||||||
|
if [ "$1" = remove ]; then
|
||||||
if [[ "$(readlink /proc/1/exe)" == */systemd ]]; then
|
deb-systemd-invoke stop telegraf.service
|
||||||
deb-systemd-invoke stop telegraf.service
|
fi
|
||||||
else
|
else
|
||||||
# Assuming sysv
|
# Assuming sysv
|
||||||
invoke-rc.d telegraf stop
|
invoke-rc.d telegraf stop
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue