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

Add time argument and wall message to shutdown #149

Open
troglobit opened this issue Feb 14, 2021 · 0 comments
Open

Add time argument and wall message to shutdown #149

troglobit opened this issue Feb 14, 2021 · 0 comments

Comments

@troglobit
Copy link
Owner

troglobit commented Feb 14, 2021

Currently shutdown is just another multicall symlink to reboot. The options have been mapped to allow for a command like shutdown -h now, but the 'now' argument is ignored,

Syntax: shutdown [opts] [timefmt] [wallmsg]

The timefmt is either of two formats +M or HH:MM, where H is hour and M minute. The now keyword is shorthand for +0. If timefmt evaluates to a a time >15 minutes, no action is taken and shutdown simply waits in the foreground until its 15 minutes left.

The wallmsg can be anything and is, along with the reboot/shutdow message, written to the file /etc/nologin, which in turn is used by other daemons to prevent users other than root to log in. This file is not created if timefmt evaluates to a time >15 minutes, as mentioned above.

When there is <= 15 minutes left to shutdown/reboot the following message is printed to the TTY of each logged in user:

Broadcast message from root (ttyN) (Sun Feb 14 02:25:28 2021):

wallmsg
The system is going DOWN for system halt in M minutes!

If no wallmsg is given and reboot has been selected:

Broadcast message from root (ttyN) (Sun Feb 14 02:25:28 2021):

The system is going DOWN for reboot in M minutes!

Just before shutdown calls init to perform the action, the following message is printed:

Broadcast message from root (ttyN) (Sun Feb 14 02:25:28 2021):

The system is going DOWN for reboot NOW!

When shutdown is called with a timefmt that evaluates to >0 minutes it can be canceled. This can be done by calling shutdown -c in another TTY. The PID of the active shutdown is available in /var/run/shutdown.pid, which also acts as a lock preventing other users to call shutdown without cancelling the active one first. Ctrl-C (SIGINT) on the active shutdown TTY also disables the countdown. When shutdown exits due to cancellation it also removes /etc/nologin.

@troglobit troglobit added this to the v4.0 milestone Feb 14, 2021
@troglobit troglobit removed this from the v4.0 milestone Feb 28, 2021
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

No branches or pull requests

1 participant