-
Notifications
You must be signed in to change notification settings - Fork 18
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
Make command line reboot go through dsme when applicable #95
Conversation
Hm, that only works for interactive mode? If applications If it's just about making the interactive experience nicer, that's a LGTM from me (but beware that some users might be using |
@thp This is mostly about convenience for command line users. But if there is some saner way to |
@@ -0,0 +1,15 @@ | |||
# Define shell functions for interactive shells only | |||
[ -z "$PS1" ] && return |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See How to check if a shell is login/interactive/batch for some other approaches. [ -z "$PS1" ]
might not always indicate interactive shell.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The same $PS1 check is used in /etc/bashrc that sources the script, the most voted solution is one liner of bashisms... I guess this should work?
case "$-" in *i*) ;; *) return ;; esac
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, or just go with the if condition? [[ $- != *i* ]] && return
And maybe copy the first paragraph here from the pull request at the top of the shell script, so people stumbling over this profile script in the future will still know the reasoning for doing this? |
Oh, and don't know of any saner way off the top of my head, so feel free to merge after copying in the description and maybe improving the "is interactive?"-check. |
Seems to work, needs to be squashed - testing would still be much appreciated. |
Users that are not deeply familiar with nemomobile can assume that running reboot utility from command line is just fine for rebooting the device. Most of the times it does work, but it also bypasses shutdown/reboot policy that is in dsme (emergency calls etc should block immediate reboot/shutdown) and causes save-data and pre-shutdown signals not to be sent / shutdown logo not shown. Simply replacing reboot, halt and poweroff utilities with other binaries is problematic since it would a) require non-upstreamable patches to systemd b) cause failures if dsme itself is down for some reason. Define shell function wrappers for reboot, poweroff, halt and shutdown. The wrapper functions use dsmetool functionality to perform reboot and shutdown. If unhandled parameters are passed to wrappers, dsme is not running or dsmetool fails for some reason, the wrappers will fall back to using systemd binaries. The wrappers are made available to interactive login shells only. Any scripts that use reboot & co commands are not affected. [dsme] Make command line reboot go through dsme when applicable. Fixes MER#1049
Squashed & commit message edited |
LGTM |
Make command line reboot go through dsme when applicable
Users that are not deeply familiar with nemomobile can assume that
running reboot utility from command line is just fine for rebooting
the device. Most of the times it does work, but it also bypasses
shutdown/reboot policy that is in dsme (emergency calls etc should
block immediate reboot/shutdown) and causes save-data and pre-shutdown
signals not to be sent / shutdown logo not shown.
Simply replacing reboot, halt and poweroff utilities with other binaries
is problematic since it would a) require non-upstreamable patches to
systemd b) cause failures if dsme itself is down for some reason.
Add aliases that make reboot, halt and poweroff attempt to do shutdown
via dsme 1st and if that fails continue with systemd helper binary.
This way reboot etc entered from interactive shell do their job via dsme.