From f13081bfbdb4897324a75a62a03f777be20081f4 Mon Sep 17 00:00:00 2001 From: Xincun Li <147451452+xincunli-sonic@users.noreply.github.com> Date: Wed, 29 Nov 2023 17:22:47 -0800 Subject: [PATCH] Ensure that 'logrotate-config.service' is set as a dependency to start before 'logrotate.service'. (#17312) * Ensure that 'logrotate-config.service' is set as a dependency to start before 'logrotate.service'. --- build_debian.sh | 4 ++++ files/image_config/logrotate/logrotate-config.service | 1 + files/image_config/logrotate/logrotateOverride.conf | 2 ++ 3 files changed, 7 insertions(+) create mode 100644 files/image_config/logrotate/logrotateOverride.conf diff --git a/build_debian.sh b/build_debian.sh index 7bdc25fb592c..991969040bae 100755 --- a/build_debian.sh +++ b/build_debian.sh @@ -461,6 +461,10 @@ fi ## Disable kexec supported reboot which was installed by default sudo sed -i 's/LOAD_KEXEC=true/LOAD_KEXEC=false/' $FILESYSTEM_ROOT/etc/default/kexec +# Ensure that 'logrotate-config.service' is set as a dependency to start before 'logrotate.service'. +sudo mkdir $FILESYSTEM_ROOT/etc/systemd/system/logrotate.service.d +sudo cp files/image_config/logrotate/logrotateOverride.conf $FILESYSTEM_ROOT/etc/systemd/system/logrotate.service.d/logrotateOverride.conf + ## Remove sshd host keys, and will regenerate on first sshd start sudo rm -f $FILESYSTEM_ROOT/etc/ssh/ssh_host_*_key* sudo cp files/sshd/host-ssh-keygen.sh $FILESYSTEM_ROOT/usr/local/bin/ diff --git a/files/image_config/logrotate/logrotate-config.service b/files/image_config/logrotate/logrotate-config.service index b965e4b32425..0b89f9d85791 100644 --- a/files/image_config/logrotate/logrotate-config.service +++ b/files/image_config/logrotate/logrotate-config.service @@ -6,6 +6,7 @@ After=updategraph.service [Service] Type=oneshot ExecStart=/usr/bin/logrotate-config.sh +RemainAfterExit=yes [Install] WantedBy=multi-user.target diff --git a/files/image_config/logrotate/logrotateOverride.conf b/files/image_config/logrotate/logrotateOverride.conf new file mode 100644 index 000000000000..adc85ff306b5 --- /dev/null +++ b/files/image_config/logrotate/logrotateOverride.conf @@ -0,0 +1,2 @@ +[Unit] +Requires=logrotate-config.service \ No newline at end of file