Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

I'd like to put a script in /etc/pm/suspend.d/ that needs network access (for a very short time) before allowing the system to suspend. However, even with scripts named "001_something" in /etc/pm/suspend.d/ and /usr/lib/pm-utils/sleep.d/ I do not get any network access. It seems this is disabled before the scripts are run.

Why is networking disabled? How can I enable it?

Also, I am unable to make use of the pm-suspend.log in /var/log. It seems the file for the suspend part is overwritten as soon as the system is resumed?

The following has been observed in daemon.log:

Feb 7 22:09:04 zenbook NetworkManager[3606]: <info> sleep requested (sleeping: no enabled: yes)·
Feb 7 22:09:04 zenbook NetworkManager[3606]: <info> sleeping or disabling...·
Feb 7 22:09:04 zenbook NetworkManager[3606]: <info> (wlan0): now unmanaged·
Feb 7 22:09:04 zenbook NetworkManager[3606]: <info> (wlan0): device state change: activated -> unmanaged (reason 'sleeping') [100 10 37]·
Feb 7 22:09:04 zenbook NetworkManager[3606]: <info> (wlan0): deactivating device (reason 'sleeping') [37]·

I am using Debian Testing with Gnome 3.

EDIT: The problem is not related to pm-utils. As far as I know, NetworkManager disables the network (in nm-manager.c:do_sleep_wake). I don't know how to solve this, yet. See NetworkManager: disabled network when sending system to sleep

share|improve this question

migrated from superuser.com Jan 22 '13 at 12:58

This question came from our site for computer enthusiasts and power users.

    
More Info: I'm using a wireless network using NetworkManager. –  C-Otto Nov 29 '12 at 16:19
    
Migrated on behalf of the OP. –  slhck Jan 22 '13 at 12:59
    
Maybe your script gets run too late, after network shutdown? –  vonbrand Jan 24 '13 at 17:40
    
I think so, yes. But how can I run it earlier? –  C-Otto Jan 24 '13 at 20:24
    
I might have confused sleep.d with suspend.d in the question, but this is not the source of the problem. –  C-Otto Feb 3 '13 at 22:54

1 Answer 1

up vote 5 down vote accepted
+50

1. Quirks?

First I would confirm that your suspend is functioning correctly. Take a look at the quirks page and confirm that your suspend is functioning correctly and not just seeming like it's working right.

2. Is your 001_something script executable?

Check to make sure that your 001_something script is executable!

% chmod +x 001_something

3. Does your 001_something script look correct?

Check to make sure your script conforms to what pm-utils is expecting.

Example script

#!/bin/bash
case "$1" in
    hibernate|suspend)
        ACTION BEFORE SUSPEND/HIBERNATE
        ;;
    thaw|resume)
        ACTION AFTER RESUME
        ;;
    *)
        ;;
esac
exit $?

NOTE: Are you putting your attempts to use the network in the hibernate|suspend correct portion of the case/switch statement?

4. file in .d directory functioning (/etc/pm/suspend.d/ or /usr/lib/pm-utils/sleep.d/)?

Next I would confirm that your 001_something script is in fact getting picked up by suspend/hibernate correctly by having it simply echo out to a file some string just so you know that it's working.

echo "yup I'm working" > /tmp/pmck_`date +%Y-%T`.log

You should then see files such as pmck_2013-16:08:11.log in /tmp.

5. /var/log?

If the above .d directory is functioning, I would make a 001_something and have it copy the /var/log/pm-suspend.log file you think is getting overwritten to some other file under /tmp, that way you can at least confirm that logging is correct. This may gain you some further insight into what's happening.

cp /var/log/pm-suspend.log /tmp/pmlg_`date +%Y-%T`.log

6. Sleep hook number?

Also can you change the name of your hook file to 00-something instead of 001_something? Not sure but the man page indicates these values.

SLEEP HOOK ORDERING CONVENTION
       00 - 49
           User and most package supplied hooks. If a hook assumes that all of the usual services and userspace infrastructure
           is still running, it should be here.

       50 - 74
           Service handling hooks. Hooks that start or stop a service belong in this range. At or before 50, hooks can assume
           that all services are still enabled.

       75 - 89
           Module and non-core hardware handling. If a hook needs to load/unload a module, or if it needs to place non-video
           hardware that would otherwise break suspend or hibernate into a safe state, it belongs in this range. At or before
           75, hooks can assume all modules are still loaded.

       90 - 99
           Reserved for critical suspend hooks.

7. Network connectivity?

Add the following to your 001_something script:

TMP=/tmp/pmip_`date +%Y-%T`.log

# network status?
ip link show > $TMP

# dns working?
dig google.com +answer >> $TMP

# can we ping google?
ping -c 5 www.google.com >> $TMP

8. Bug with pm-utils, HAL, and Wheezy?

I came across this debian bug report and wonder if this might be the cause of your problem. The bug describes an issue with HAL and pm-utils. It sounds like removing HAL fixes the networking issue.

9. More verbose pm-utils debugging

Additionally there is this link which offers advice for suspend/resume issues specific to Debian. There is mention of a way to increase the logging of pm-utils by setting a variable, PM_DEBUG=true in the /usr/lib/pm-utils/pm-functions file.

excerpt

Enabling Debugging for pm-utils

The log of suspend and resume processes are in file /var/log/pm-suspend.log. It contains moderately verbose information by default. More information can be enabled for debugging by inserting line export PM_DEBUG=true into the beginning of file /usr/lib/pm-utils/pm-functions.

Perhaps this might be helpful in giving you more insight into what's going on with pm-utils!

10. ACPI shutting down network prior to pm-utils?

If the issue doesn't appear to be with pm-utils, it may be because of acpi. When you close the lid on your laptop, an acpi event is triggered, that event has an action associated to it.

EVENT File

% more /etc/acpi/events/lm_lid
event=button[ /]lid
action=/etc/acpi/actions/lm_lid.sh %e

ACTION File

% more /etc/acpi/actions/lm_lid.sh
#! /bin/sh

test -f /usr/sbin/laptop_mode || exit 0

# lid button pressed/released event handler

/usr/sbin/laptop_mode auto

Taking a closer look at laptop_mode you'll see that this tool is responsible for doing a variety of things, one of which is managing the status of your network devices.

laptop-mode maintains a directory, /etc/laptop-mode/conf.d, similar to other unix tools. In there are files related to the ethernet and wireless networking devices.

In the primary config. file, /etc/laptop-mode/laptop-mode.conf, is the ability to turn on more verbose messaging. Perhaps this will shed some additional light on what's going on?

VERBOSE_OUTPUT=1

Summary of above things to try based on the OP's feedback

1: Suspend works as far as battery usage and the sleep LED on my notebook are concerned. Otherwise I do not understand how the mentioned web page should help me find out.

2: It is.

3: It looks correct.

4: I get those files.

5: I get the corresponding log files, but these are not helpful to me.

6: 00 instead of 001 does not show any difference.

7: Things in this section just test for network connectivity. As said in my question, I do not have network connectivity as soon as the script is run. The wlan0 device is down. The log files: http://paste.debian.net/231760.

NOTE: I did not have dig installed (error msg. in paste.debian.net log), however it is clear that no network access is available (as said). I can see that it is down by inspecting the output of iwconfig, ip link show, ping, ... The perl script is the script in question.

BTW, as soon as the first line of /usr/lib/pm-utils/bin/pm-action is executed (from upowerd), the network is down already.

8: hal was installed, removing it does not change anything.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.