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

Create /var/run/reboot-required file #196

Merged
merged 1 commit into from May 18, 2023
Merged

Create /var/run/reboot-required file #196

merged 1 commit into from May 18, 2023

Conversation

FrostyX
Copy link
Owner

@FrostyX FrostyX commented May 17, 2023

Fix #195

@FrostyX
Copy link
Owner Author

FrostyX commented May 17, 2023

if not self.applications.count_type(Applications.TYPES["STATIC"]):
return
with open("/var/run/reboot-required", "w") as fp:
fp.write("Tracer says reboot is required\n")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can this be written more cleanly:

		if self.applications.count_type(Applications.TYPES["STATIC"]):
			with open("/var/run/reboot-required", "w") as fp:
                        ...

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, updated

@major
Copy link

major commented May 18, 2023

So I tried the code from this PR and I didn't see the file being written. Perhaps I didn't do something correctly.

Output:

You should restart:
  * Some applications using:
      sudo systemctl restart NetworkManager
      sudo systemctl restart auditd
      sudo systemctl restart chronyd
      sudo systemctl restart dbus-broker
      sudo systemctl restart qemu-guest-agent
      sudo systemctl restart sshd
      sudo systemctl restart systemd-journald
      sudo systemctl restart systemd-logind
      sudo systemctl restart systemd-oomd
      sudo systemctl restart systemd-resolved
      sudo systemctl restart systemd-udevd
      sudo systemctl restart systemd-userdbd

  * These applications manually:
      (sd-pam)
      dnf

Additionally, there are:
  - 3 processes requiring restart of your session (i.e. Logging out & Logging in again)
  - 1 processes requiring reboot

For more information run:
    sudo tracer -iat 1684410627.5498843

But no file was written:

[root@tracer-testing ~]# cat /var/run/reboot-required
cat: /var/run/reboot-required: No such file or directory

@major
Copy link

major commented May 18, 2023

Nevermind -- an update in F38 clobbered the testing RPM from this change. This works just fine! 🥳

[root@tracer-testing ~]# tracer 
You should restart:
  * Some applications using:
      sudo systemctl restart NetworkManager
      sudo systemctl restart auditd
      sudo systemctl restart chronyd
      sudo systemctl restart dbus-broker
      sudo systemctl restart qemu-guest-agent
      sudo systemctl restart sshd
      sudo systemctl restart systemd-journald
      sudo systemctl restart systemd-logind
      sudo systemctl restart systemd-oomd
      sudo systemctl restart systemd-resolved
      sudo systemctl restart systemd-udevd
      sudo systemctl restart systemd-userdbd

  * These applications manually:
      (sd-pam)

Additionally, there are:
  - 3 processes requiring restart of your session (i.e. Logging out & Logging in again)
  - 1 processes requiring reboot
[root@tracer-testing ~]# cat /var/run/reboot-required 
Tracer says reboot is required

@FrostyX
Copy link
Owner Author

FrostyX commented May 18, 2023

Perfect, thank you for the test.

@FrostyX FrostyX merged commit fe8a4e8 into master May 18, 2023
@@ -136,6 +137,15 @@ def status_code(self):
code = 104
return code

def create_reboot_required_file(self):
"""
If a reboot is needed, create a /var/run/reboot-required file.
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The correct location is /run, not /var/run. In most cases, this doesn't matter greatly, because a compat symlink is provided, but when /var is a separate partition, /var/run would only be accessible if /var is mounted, i.e. rather late in boot. /run is always available. /var/run is a compat symlink that should not be used (esp. in new code).

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you @keszybz,
if I change the location, will this be okay with you @major?

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@FrostyX should be fine!

FrostyX added a commit that referenced this pull request Jun 18, 2023
See #196 (comment)

> The correct location is /run, not /var/run. In most cases, this
> doesn't matter greatly, because a compat symlink is provided, but when
> /var is a separate partition, /var/run would only be accessible if
> /var is mounted, i.e. rather late in boot. /run is always
> available. /var/run is a compat symlink that should not be
> used (esp. in new code).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

RFE: Write /var/run/reboot-required if reboot is needed
4 participants