LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Slackware (https://www.linuxquestions.org/questions/slackware-14/)
-   -   Correct way to resume networking using /etc/rc.d/rc.inet1 (https://www.linuxquestions.org/questions/slackware-14/correct-way-to-resume-networking-using-etc-rc-d-rc-inet1-4175580817/)

navigium 05-27-2016 01:46 AM

Correct way to resume networking using /etc/rc.d/rc.inet1
 
Hey all,

I just fixed the problem that my laptop (on which I refuse to use wicd or NetworkManager) doesn't reconnect to the wifi when I resume from suspend. I just copied the file /usr/lib64/pm-utils/55wicd to /etc/pm/sleep.d/55networking and modified it as follows:

Code:

#!/bin/sh

# pm-utils hook to handle suspend/resume properly for wicd

if [ -r "${PM_FUNCTIONS}" ]; then
        . "${PM_FUNCTIONS}"
elif [ -r "${FUNCTIONS}" ]; then
        . "${FUNCTIONS}"
else
        # pm-utils version is too old, or something else is wrong
        exit $NA
fi

RETVAL=0        # Set this to 0 initially

net_suspend()
{
        # Put wifi interface down
        /etc/rc.d/rc.inet1 stop 1>/dev/null 2>/dev/null
        RETVAL=$?
}

net_resume()
{
        # Bring wifi interface back up
        /etc/rc.d/rc.inet1 start 1>/dev/null 2>/dev/null
        RETVAL=$?
}

case "$1" in
        hibernate|suspend)
                net_suspend
                ;;
        thaw|resume)
                net_resume
                ;;
        *) exit $NA
                ;;
esac

# We can't return a nonzero exit code (aside from $NA, $DX, and $NX) to
# to pm-utils or the entire sleep operation will be inhibited, so...
# No matter what we do, the log prefix and message will conflict a bit.
case "$RETVAL" in
        0)
                exit $RETVAL
                ;;
        *)
                echo "Error reconnecting to the network"
                exit $NA
                ;;
esac

Now I've got two questions:
  • Is this the correct way to solve this problem?
  • Why doesn't Slackware come with this resume script for rc.inet1? (Or if it does: Where do I find it?)

business_kid 05-27-2016 05:09 AM

I'm running Slackware-14.1, and no wicd or NetworkManager, on which I share your views.
I have to do no fancy work for network resumption. I use XFCE - No time for high cholesterol WMs. Have you discovered pm-suspend & pm-hibernate?

There are minor irrations around usb disks on resuming, but that's because I'm lazy.

navigium 05-27-2016 05:37 AM

Quote:

Originally Posted by business_kid (Post 5551661)
I'm running Slackware-14.1, and no wicd or NetworkManager, on which I share your views.
I have to do no fancy work for network resumption. I use XFCE - No time for high cholesterol WMs. Have you discovered pm-suspend & pm-hibernate?

There are minor irrations around usb disks on resuming, but that's because I'm lazy.

Oh, I thought this would be a problem for everyone. According to my ACPI scrip I run pm-suspend when I close my laptop lid. According to its documentation, pm-suspend then runs the scripts in /etc/pm/sleep.d with the parameter "suspend" and again when resuming with the parameter "resume". At least that's how I think it works.

I run i3wm without a DE. Maybe XFCE might do some magic to resume your network connection. Are you on wifi using wpa_supplicant? If not this might be the reason for my problem and I might be able to tell wpa_supplicant to reconnect somehow.

business_kid 05-28-2016 04:30 AM

I've a Samsung laptop, and the Bios are fairly sound in power management, but teetotally OTT in UEFI. UEFI is disabled, & disk replaced with ssd formatted with fdisk, not gdisk. Using gdisk invokes uefi again.

Then the only issue was XFCE'S power manager. The Bios did everything, & XFCE'S power manager did it again, so I suspended/hibernated twice for every button pressed. I chose to neuter XFCE & run on the bios.If your bios are dodgy, you might try disabling them & using the power manager. This is wherte you are really found out if your wm is half-assed because these things are not sorted.

Yes, I have wpa_supplicant & wifi. It deletes the routes on suspend (192.168.178.26 & 192.168.178.0/24) & rebinds the leases on resume. That's all. cfg80211 seems to get a lot of mention in the logs

navigium 05-28-2016 10:27 AM

Quote:

Originally Posted by business_kid (Post 5552118)
I've a Samsung laptop, and the Bios are fairly sound in power management, but teetotally OTT in UEFI. UEFI is disabled, & disk replaced with ssd formatted with fdisk, not gdisk. Using gdisk invokes uefi again.

Then the only issue was XFCE'S power manager. The Bios did everything, & XFCE'S power manager did it again, so I suspended/hibernated twice for every button pressed. I chose to neuter XFCE & run on the bios.If your bios are dodgy, you might try disabling them & using the power manager. This is wherte you are really found out if your wm is half-assed because these things are not sorted.

Yes, I have wpa_supplicant & wifi. It deletes the routes on suspend (192.168.178.26 & 192.168.178.0/24) & rebinds the leases on resume. That's all. cfg80211 seems to get a lot of mention in the logs

I do run XFCE's power manager in the background, this might well be the source of the problem. My BIOS is SeaBIOS on Coreboot (on a Chromebook). There isn't a lot I'm able to change (because I have no clue how to build coreboot with SeaBIOS and bake them into a flashable ROM.) Thanks for the tip, I'll check this out. I don't think it's the wm's fault, it happened with every wm I tried that don't come with a full DE (openbox, fvwm, i3, wmaker) and after all the wm shouldn't interfere with network connectivity anyway.

Tonus 05-29-2016 02:32 PM

Correct way to resume networking using /etc/rc.d/rc.inet1
 
I run i3 without any DE and wicd reconnects on resume (must have the option "connect automatically" on a reachable ap I guess). So You're right, the trouble might come from hardware / bios...

Btw, I have in my todo list "find a good and working script / rule for acpi to suspend or hibernate on low bat". Do you have one you would share ?

business_kid 05-30-2016 01:01 AM

I looked into that but since the move of power stuff from /proc to /sys it's not that easy.
XFCE Power manager uses a battery percentage & triggers on it. You can try polling /sys/power/<your-battery>/state for an 'emergency' state, but I never got a reliable script together.


All times are GMT -5. The time now is 04:59 PM.