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

Make command line reboot go through dsme when applicable #95

Merged
merged 1 commit into from
Jun 3, 2015
Merged

Make command line reboot go through dsme when applicable #95

merged 1 commit into from
Jun 3, 2015

Conversation

spiiroin
Copy link
Contributor

@spiiroin spiiroin commented Jun 1, 2015

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.

@thp
Copy link

thp commented Jun 1, 2015

Hm, that only works for interactive mode? If applications exec() reboot, that wouldn't do the right thing? What if dsme would do (the RPM-world equivalent thing of dpkg-divert)? Or is that overkill?

If it's just about making the interactive experience nicer, that's a LGTM from me (but beware that some users might be using zsh or a different shell.. ;).

@spiiroin
Copy link
Contributor Author

spiiroin commented Jun 1, 2015

@thp This is mostly about convenience for command line users. But if there is some saner way to
handle it, I'm all ears.

@@ -0,0 +1,15 @@
# Define shell functions for interactive shells only
[ -z "$PS1" ] && return
Copy link

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.

Copy link
Contributor Author

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

Copy link

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

@thp
Copy link

thp commented Jun 1, 2015

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?

@thp
Copy link

thp commented Jun 1, 2015

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.

@spiiroin
Copy link
Contributor Author

spiiroin commented Jun 2, 2015

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
@spiiroin
Copy link
Contributor Author

spiiroin commented Jun 3, 2015

Squashed & commit message edited

@thp
Copy link

thp commented Jun 3, 2015

LGTM

spiiroin added a commit that referenced this pull request Jun 3, 2015
Make command line reboot go through dsme when applicable
@spiiroin spiiroin merged commit f1a81ed into nemomobile:master Jun 3, 2015
@spiiroin spiiroin deleted the mer1049_reboot_alias branch June 3, 2015 07:48
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.

2 participants