summaryrefslogtreecommitdiff
path: root/pm/power.d/disable_wol
blob: 027eec55b6a6bc5058b89e44d9ffec95b1da245a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
#!/bin/sh

. "${PM_FUNCTIONS}"

command_exists ethtool || exit $NA

set_wol_status() {
    for d in "/sys/class/net/"*; do
	[ -f "$d/wireless" ] && continue
	[ -h "$d/device/driver" ] || continue
	printf "Setting Wake On Lan for %s to %s..." "${d##*/}" "$1"
	case $1 in
	    disable) ethtool -s "${d##*/}" wol d>/dev/null 2>&1;;
	    enable) ethtool -s "${d##*/}" wol g>/dev/null 2>&1;;
	esac
	[ "$?" -eq 0 ] && echo Done. || echo Failed.
    done
}

case $1 in
    true) set_wol_status disable;;
    false) set_wol_status enable;;
    *) exit $NA;;
esac

exit 0