-
Notifications
You must be signed in to change notification settings - Fork 29
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
rpm: don't always fire v4 restart process
Before: * if td-agent.service is enabled mark enabled state * if td-agent.service is active, but fluentd user does not exist, stop td-agent and create fluentd user. To make it enabled, restart service later. After: * only execute v4 migration with restart process when v4 migration phase is executed. It might be a bug for v5.x Signed-off-by: Kentaro Hayashi <[email protected]>
- Loading branch information
Showing
1 changed file
with
21 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -217,29 +217,29 @@ if [ $1 -eq 1 ]; then | |
rm -f /etc/@PACKAGE_DIR@/@[email protected] | ||
ln -sf /etc/@PACKAGE_DIR@/@[email protected] /etc/@PACKAGE_DIR@/@[email protected] | ||
fi | ||
fi | ||
if systemctl is-enabled @COMPAT_SERVICE_NAME@; then | ||
# It is not enough to systemctl enable fluentd here for taking over enabled service status | ||
# because td-agent %preun disables td-agent so fluentd is also disabled. | ||
touch %{v4migration_enabled_service} | ||
fi | ||
if systemctl is-active @COMPAT_SERVICE_NAME@; then | ||
if getent passwd @COMPAT_SERVICE_NAME@ >/dev/null; then | ||
if ! getent passwd @SERVICE_NAME@ >/dev/null; then | ||
# usermod fails when user process is active, so | ||
# postpone username migration step here. (During %pre | ||
# stage, mismatch of user/group configuration cause | ||
# restarting service failure.) | ||
systemctl stop @COMPAT_SERVICE_NAME@.service | ||
TD_UID=$(id --user @COMPAT_SERVICE_NAME@) | ||
TD_GID=$(getent group @COMPAT_SERVICE_NAME@ | cut -d':' -f3) | ||
/usr/sbin/useradd -u $TD_UID -g $TD_GID -o @SERVICE_NAME@ | ||
if systemctl is-enabled @COMPAT_SERVICE_NAME@; then | ||
# It is not enough to systemctl enable fluentd here for taking over enabled service status | ||
# because td-agent %preun disables td-agent so fluentd is also disabled. | ||
touch %{v4migration_enabled_service} | ||
fi | ||
if systemctl is-active @COMPAT_SERVICE_NAME@; then | ||
if getent passwd @COMPAT_SERVICE_NAME@ >/dev/null; then | ||
if ! getent passwd @SERVICE_NAME@ >/dev/null; then | ||
# usermod fails when user process is active, so | ||
# postpone username migration step here. (During %pre | ||
# stage, mismatch of user/group configuration cause | ||
# restarting service failure.) | ||
systemctl stop @[email protected] | ||
TD_UID=$(id --user @COMPAT_SERVICE_NAME@) | ||
TD_GID=$(getent group @COMPAT_SERVICE_NAME@ | cut -d':' -f3) | ||
/usr/sbin/useradd -u $TD_UID -g $TD_GID -o @SERVICE_NAME@ | ||
fi | ||
fi | ||
# Want to restart with new user/group here, | ||
# but to avoid holding file descriptor under /var/log/@COMPAT_PACKAGE_DIR@/, | ||
# delay restarting @SERVICE_NAME@ service. | ||
touch %{v4migration_with_restart} | ||
fi | ||
# Want to restart with new user/group here, | ||
# but to avoid holding file descriptor under /var/log/@COMPAT_PACKAGE_DIR@/, | ||
# delay restarting @SERVICE_NAME@ service. | ||
touch %{v4migration_with_restart} | ||
fi | ||
if [ -d /var/log/@COMPAT_PACKAGE_DIR@ -a ! -h /var/log/@COMPAT_PACKAGE_DIR@ ]; then | ||
# /var/log/@COMPAT_PACKAGE_DIR@ migration from v4 | ||
|