chore: Create default statefile and folder during package install (#13306)

This commit is contained in:
Joshua Powers 2023-05-24 07:38:32 -06:00 committed by GitHub
parent 5237d569d7
commit 225a82ca6b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 28 additions and 0 deletions

View File

@ -51,6 +51,20 @@ test -d $LOG_DIR || 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 -h "$STATE_FILE"
chown root:telegraf "$STATE_FILE"
chmod 660 "$STATE_FILE"
}
if [ -d /run/systemd/system ]; then
install_systemd /lib/systemd/system/telegraf.service
# if and only if the service was already running then restart

View File

@ -30,6 +30,20 @@ test -d $LOG_DIR || 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 -h "$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