You are not logged in.

#1 2012-07-12 16:48:50

Gazpacho
Member
Registered: 2011-11-05
Posts: 17

Restart Systemd service after laptop resume

Hi!

After resume my laptop (from suspend, I've no tried hibernation) I need to restart NetworkManager service. How can I do this automaticaly?, I've searched in google and Systemd documentation but I have not a clear idea about how to do it.

thanks

Offline

#2 2012-07-19 10:42:07

johnislarry
Member
From: Seattle, WA, USA
Registered: 2010-08-18
Posts: 19
Website

Re: Restart Systemd service after laptop resume

This was a long time ago it seems, so perhaps you've solved the problem, but if your situation involves you typing a command to suspend, i.e.

 s2ram 

then you could alias the command in your .bashrc to be something like

 alias 'standby' s2ram && /etc/rc.d/networkmanager restart 

Does that seem like a good solution? I guess it's kind of a hack, maybe there's a dispatcher for the suspend utility you're using that runs a script on resume.

Offline

#3 2012-07-19 20:00:46

boast
Member
Registered: 2010-09-28
Posts: 219

Re: Restart Systemd service after laptop resume

Would putting a script in /etc/pm/sleep.d/ to restart it work for you?


Asus M4A785TD-V ;; Phenom II X4 @ 3.9GHz ;; Ripjaws 12GB DDR3-1600 ;; 128GB Samsung 830 ;; MSI GTX460 v2 w/ blob ;; Arch Linux + KDE 4.x

Offline

#4 2012-07-20 23:12:50

tomegun
Developer
From: France
Registered: 2010-05-28
Posts: 661

Re: Restart Systemd service after laptop resume

Having to restart NM is clearly a bug. I'm not able to reproduce it here, but please file a bug report if it is still an issue.

Offline

#5 2012-07-22 16:47:36

Gazpacho
Member
Registered: 2011-11-05
Posts: 17

Re: Restart Systemd service after laptop resume

tomegun wrote:

Having to restart NM is clearly a bug. I'm not able to reproduce it here, but please file a bug report if it is still an issue.

I don't know where can I find util information for the bug. "dmesg" does not offer information about Network Manager

@boast, @johnislarry. I'm using systemd, so I can't try your solutions, but thanks for your interest

Offline

#6 2012-07-22 17:05:48

lucke
Member
From: Poland
Registered: 2004-11-30
Posts: 4,018

Re: Restart Systemd service after laptop resume

As boast said, you can make pm-utils run "systemctl restart networkmanager.service" after resume for you. https://wiki.archlinux.org/index.php/Pm … _own_hooks

Offline

#7 2012-07-22 17:37:13

Gazpacho
Member
Registered: 2011-11-05
Posts: 17

Re: Restart Systemd service after laptop resume

lucke wrote:

As boast said, you can make pm-utils run "systemctl restart networkmanager.service" after resume for you. https://wiki.archlinux.org/index.php/Pm … _own_hooks

Sorry (to boast too), you are right. I've read the wiki and created a hook, now NM restarts after resume. Thanks!

And now I've discovered that my computer only suspends the first time. Second time nothing happens when I close the tap, execute pm-suspend or the KDE menu option suspend to ram

If you have any idea it is welcome. If not I will mark the thread as solved in a couple of days and search in forums and wiki.

Offline

#8 2012-07-22 17:42:42

65kid
Member
From: Germany
Registered: 2011-01-26
Posts: 663

Re: Restart Systemd service after laptop resume

Gazpacho wrote:
lucke wrote:

As boast said, you can make pm-utils run "systemctl restart networkmanager.service" after resume for you. https://wiki.archlinux.org/index.php/Pm … _own_hooks

Sorry (to boast too), you are right. I've read the wiki and created a hook, now NM restarts after resume. Thanks!

And now I've discovered that my computer only suspends the first time. Second time nothing happens when I close the tap, execute pm-suspend or the KDE menu option suspend to ram

If you have any idea it is welcome. If not I will mark the thread as solved in a couple of days and search in forums and wiki.

this usually happens when your hook doesn't exit. pm-suspend never finishes because it's waiting for the hook to exit and the second pm-suspend will block until the other pm-suspend is finished. Please post your hook.

Offline

#9 2012-07-22 18:16:29

Gazpacho
Member
Registered: 2011-11-05
Posts: 17

Re: Restart Systemd service after laptop resume

65kid wrote:

this usually happens when your hook doesn't exit. pm-suspend never finishes because it's waiting for the hook to exit and the second pm-suspend will block until the other pm-suspend is finished. Please post your hook.

I've two scripts

# 50networkmanager
case $1 in
    hibernate)
        echo "Hey guy, we are going to suspend to disk!"
        ;;
    suspend)
        echo "Oh, this time we are doing a suspend to RAM. Cool!"
        ;;
    thaw)
        echo "Oh, suspend to disk is over, we are resuming..."
        ;;
    resume)
        systemctl restart networkmanager.service
        ;;
    *)  echo "Somebody is calling me totally wrong."
        ;;
esac
# 90alsa: suspend/wakeup ALSA devices

case "$1" in
hibernate|suspend)
;;
thaw|resume)
aplay -d 1 /dev/zero
;;
*) exit $NA
;;
esac

Offline

#10 2012-07-22 18:21:54

65kid
Member
From: Germany
Registered: 2011-01-26
Posts: 663

Re: Restart Systemd service after laptop resume

does the problem only happen with your networkmanager hook? because this looks fine, "systemctl restart" shouldn't take that long.
there was a similiar case recently on the mailing list where this supposedly was caused by the alsa hook:
http://mailman.archlinux.org/pipermail/ … 27713.html

but anyway, keep tomeguns' advice in mind. Better create a bug report instead of using these kind of ugly workarounds.

Offline

Board footer

Powered by FluxBB