Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: only execute "init_config" on install (2.6) #24494

Merged
merged 1 commit into from
Dec 1, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
82 changes: 69 additions & 13 deletions .circleci/scripts/package/influxdb2/control/postinst
Original file line number Diff line number Diff line change
Expand Up @@ -95,35 +95,80 @@ if [[ -L /etc/init.d/influxdb ]]; then
rm -f /etc/init.d/influxdb
fi

# Distribution-specific logic
if [[ -f /etc/redhat-release ]]; then
# RHEL-variant logic
function redhat() {
if command -v systemctl &>/dev/null; then
install_systemd
else
# Assuming sysv
install_init
install_chkconfig
fi
elif [[ -f /etc/debian_version ]]; then

case ${1} in
1)
# on-install
if should_upgrade; then
upgrade_notice
else
# Only execute "init_config" during "on-install". If the configuration
# is absent during "on-upgrade", assume that this it is an intentional
# choice by the system administrator. Writing default configuration
# after "influxd" has executed without *any* configuration, causes
# "influxd" to execute with different "bolt-path" and "engine"
# directories resulting in the perception of data loss.
init_config
fi
;;
2)
# on-upgrade
if should_upgrade; then
upgrade_notice
fi
;;
esac
}

function debian() {
# Ownership for RH-based platforms is set in build.py via the `rmp-attr` option.
# We perform ownership change only for Debian-based systems.
# Moving these lines out of this if statement would make `rmp -V` fail after installation.
# We perform ownership change only for Debian-based systems. Moving these lines
# out of this if statement would make `rmp -V` fail after installation.
chown -R -L influxdb:influxdb $LOG_DIR
chown -R -L influxdb:influxdb $DATA_DIR
chmod 755 $LOG_DIR
chmod 755 $DATA_DIR

# Debian/Ubuntu logic
if command -v systemctl &>/dev/null; then
install_systemd
else
# Assuming sysv
install_init
install_update_rcd
fi
elif [[ -f /etc/os-release ]]; then

if [[ ! "${2:-}" ]]; then
# on-install
if should_upgrade; then
upgrade_notice
else
# Only execute "init_config" during "on-install". If the configuration
# is absent during "on-upgrade", assume that this it is an intentional
# choice by the system administrator. Writing default configuration
# after "influxd" has executed without *any* configuration, causes
# "influxd" to execute with different "bolt-path" and "engine"
# directories resulting in the perception of data loss.
init_config
fi
else
# on-upgrade
if should_upgrade; then
upgrade_notice
fi
fi
}

function amazon() {
source /etc/os-release

if [[ "$NAME" = "Amazon Linux" ]]; then
# Amazon Linux 2+ logic
install_systemd
Expand All @@ -132,11 +177,22 @@ elif [[ -f /etc/os-release ]]; then
install_init
install_chkconfig
fi

if should_upgrade; then
upgrade_notice
else
init_config
fi
}

if [[ "${RPM_INSTALL_PREFIX:-}" ]]; then
redhat "${@}"
exit 0
fi

# Check upgrade status
if should_upgrade; then
upgrade_notice
else
init_config
if [[ "${DPKG_RUNNING_VERSION:-}" ]]; then
debian "${@}"
exit 0
fi

amazon "${@}"
Loading