Skip to content

Commit

Permalink
deb:rpm: migrate existing config as default config
Browse files Browse the repository at this point in the history
Signed-off-by: Daijiro Fukuda <fukuda@clear-code.com>
  • Loading branch information
daipom committed Jul 26, 2023
1 parent 17c1fdb commit 95a8559
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 16 deletions.
4 changes: 3 additions & 1 deletion fluent-package/apt/systemd-test/update-from-v4.sh
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,9 @@ systemctl status --no-pager td-agent
systemctl status --no-pager fluentd

# Test: config migration
test -L /etc/td-agent
test -h /etc/td-agent
test -h /etc/fluent/fluentd.conf
test $(readlink "/etc/fluent/fluentd.conf") = "/etc/fluent/td-agent.conf"
test -e /etc/td-agent/td-agent.conf

# Test: log file migration
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,15 +66,23 @@ migration_from_v4_main_process() {
echo "Migrating from /etc/<%= compat_service_name %>/plugin/ to /etc/<%= package_dir %>/plugin/..."
mv -f /etc/<%= compat_service_name %>/plugin/* /etc/<%= package_dir %>/plugin/
fi
create_link_for_config=n
if [ -f /etc/<%= compat_package_dir %>/<%= compat_service_name %>.conf -a ! -e /etc/<%= compat_package_dir %>/<%= service_name %>.conf ]; then
create_link_for_config=y
fi
if [ -f /etc/<%= compat_package_dir %>/<%= compat_service_name %>.conf ]; then
echo "Migrating from /etc/<%= compat_package_dir %>/<%= compat_service_name %>.conf to /etc/<%= package_dir %>/<%= compat_service_name %>.conf"
cp -f /etc/<%= compat_package_dir %>/<%= compat_service_name %>.conf /etc/<%= package_dir %>/<%= compat_service_name %>.conf
for d in $(ls /etc/<%= compat_package_dir %>); do
if [ ! "$d" = "plugin" -a ! "$d" = "<%= compat_service_name %>.conf" ]; then
# except managed under deb files must be migrated
mv -f /etc/<%= compat_package_dir %>/$d /etc/<%= package_dir %>/
fi
done
fi
for d in $(ls /etc/<%= compat_package_dir %>); do
if [ ! "$d" = "plugin" -a ! "$d" = "<%= compat_service_name %>.conf" ]; then
# except managed under deb files must be migrated
mv -f /etc/<%= compat_package_dir %>/$d /etc/<%= package_dir %>/
fi
done
if [ $create_link_for_config = "y" ]; then
rm -f /etc/<%= package_dir %>/<%= service_name %>.conf
ln -sf /etc/<%= package_dir %>/<%= compat_service_name %>.conf /etc/<%= package_dir %>/<%= service_name %>.conf
fi
fi
if [ -h /etc/systemd/system/td-agent.service ]; then
Expand Down
20 changes: 13 additions & 7 deletions fluent-package/yum/fluent-package.spec.in
Original file line number Diff line number Diff line change
Expand Up @@ -192,13 +192,19 @@ if [ $1 -eq 1 ]; then
echo "Migrating from /etc/@COMPAT_PACKAGE_DIR@/plugin/ to /etc/@PACKAGE_DIR@/plugin/..."
mv -f /etc/@COMPAT_PACKAGE_DIR@/plugin/* /etc/@PACKAGE_DIR@/plugin/
fi
if [ -f /etc/@COMPAT_PACKAGE_DIR@/@COMPAT_SERVICE_NAME@.conf ]; then
for d in /etc/@COMPAT_PACKAGE_DIR@/*; do
if [ ! "$d" == "/etc/@COMPAT_PACKAGE_DIR@/plugin" ]; then
echo "Migrating from $d to /etc/@PACKAGE_DIR@/..."
mv -f $d /etc/@PACKAGE_DIR@/
fi
done
create_link_for_config=n
if [ -f /etc/@COMPAT_PACKAGE_DIR@/@COMPAT_SERVICE_NAME@.conf -a ! -e /etc/@COMPAT_PACKAGE_DIR@/@SERVICE_NAME@.conf ]; then
create_link_for_config=y
fi
for d in /etc/@COMPAT_PACKAGE_DIR@/*; do
if [ ! "$d" == "/etc/@COMPAT_PACKAGE_DIR@/plugin" ]; then
echo "Migrating from $d to /etc/@PACKAGE_DIR@/..."
mv -f $d /etc/@PACKAGE_DIR@/
fi
done
if [ $create_link_for_config = "y" ]; then
rm -f /etc/@PACKAGE_DIR@/@SERVICE_NAME@.conf
ln -sf /etc/@PACKAGE_DIR@/@COMPAT_SERVICE_NAME@.conf /etc/@PACKAGE_DIR@/@SERVICE_NAME@.conf
fi
fi
if systemctl is-active @COMPAT_SERVICE_NAME@; then
Expand Down
6 changes: 4 additions & 2 deletions fluent-package/yum/systemd-test/update-from-v4.sh
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,13 @@ sudo systemctl enable --now fluentd
systemctl status --no-pager td-agent

# Test: config migration
test -L /etc/td-agent
test -h /etc/td-agent
test -h /etc/fluent/fluentd.conf
test $(readlink "/etc/fluent/fluentd.conf") = "/etc/fluent/td-agent.conf"
test -e /etc/td-agent/td-agent.conf

# Test: log file migration
test -L /var/log/td-agent
test -h /var/log/td-agent
test -e /var/log/td-agent/td-agent.log

# Test: bin file migration
Expand Down

0 comments on commit 95a8559

Please sign in to comment.