Comment 17 for bug 771857

Revision history for this message
Richard Elkins (texadactyl) wrote :

A couple of automated work-arounds follows, depending on which version of the Ubuntu core you are using.

==========================================
BEFORE systemd (earlier than Ubuntu 15.04)
==========================================

Create the following executable Bourne shell script in /etc/pm/sleep.d:

MYNAME=`basename`

restart_ethernet() {
   /usr/bin/logger $MYNAME 'restart_ethernet(r8169) BEGIN'
   /sbin/modprobe -v -r r8169
   /sbin/modprobe -v r8169
   /usr/bin/logger $MYNAME 'restart_ethernet(r8169) END'
}

/usr/bin/logger $MYNAME 'case=[' ${1} ']'
case "${1}" in
   hibernate|suspend) ;;
   resume|thaw) restart_ethernet;;
esac

=====================================
WITH systemd (Ubuntu 15.04 and later)
=====================================

1. Create executable Bourne shell script, /usr/local/bin/resume_r8169.sh:
MYNAME=`basename`
/usr/bin/logger $MYNAME 'restart_ethernet(r8169) BEGIN'
modprobe -v -r r8169
modprobe -v r8169
/usr/bin/logger $MYNAME 'restart_ethernet(r8169) END'

2. In /etc/systemd/system, create resume_r8169.service that looks like this:
[Unit]
Description=Work-around r8169 inability to resume service after suspend
After=suspend.target

[Service]
User=root
Type=oneshot
ExecStart=/bin/sh -c /usr/local/bin/resume_r8169.sh
TimeoutSec=0
StandardOutput=syslog

[Install]
WantedBy=suspend.target

3. sudo systemctl enable /etc/systemd/system/resume_r8169.service