Debian Codegraph @

setup/files/misc/arm-wol

raw symbols SCIP
1 #!/bin/bash
2 # Author: Steven Shiau <steven _at_ clonezilla org>
3 # License: GPL
4 #
5 # To arm wake on LAN for NIC in DRBL client.
6 #
7 # chkconfig: 2345 99 99
8 # description: To arm wake on LAN for NIC in DRBL client before it poweroffs.
9 # Author: Steven Shiau <steven _at_ clonezilla org>
10 # License: GPL
11 #
12 # For SuSE insserv
13 ### BEGIN INIT INFO
14 # Provides: arm-wol
15 # Required-Start:
16 # Required-Stop:
17 # X-UnitedLinux-Should-Start:
18 # X-UnitedLinux-Should-Stop:
19 # Default-Start: 2 3 4 5
20 # Default-Stop: 0 1 6
21 # Description: To arm wake on LAN for NIC in DRBL client before it poweroffs.
22 ### END INIT INFO
23
24 # Append a default search path.
25 PATH="$PATH:/sbin:/usr/sbin:/bin:/usr/bin:/usr/X11R6/bin"
26 export PATH
27
28 #
29 if [ ! "$UID" = "0" ]; then
30 echo
31 echo "[$LOGNAME] You need to run this script \"`basename $0`\" as root."
32 echo
33 exit 1
34 fi
35
36 # Exclude some devices, like lo, sit0, vmnet... It's regular expression.
37 exluding_dev="(lo|sit[0-9]+|vmnet)"
38 export LC_ALL=C
39 if [ -d /sys/class/net/ ]; then
40 # kernel support sysfs, so get the NIC devices from /sys
41 NETDEVICES="$(unalias ls &>/dev/null; ls /sys/class/net/ | grep -v -E "$exluding_dev")"
42 elif [ -f /proc/net/dev ]; then
43 # kernel do not support sysfs, so get the NIC devices from /proc
44 NETDEVICES="$(cat /proc/net/dev | grep "^.*:" | cut -d: -f1 | grep -v -E "$exluding_dev")"
45 else
46 echo "Network interface card is not found in /sys/class/net/ or /proc/net/dev!"
47 echo "Program terminated!"
48 exit 1
49 fi
50 echo -n "Trying to arm the wake on LAN for "
51 RETVAL=0
52 for nic in $NETDEVICES; do
53 echo -n "$nic... "
54 ethtool -s $nic wol g &> /dev/null
55 RETVAL="$((RETVAL+$?))"
56 done
57 echo "done!"
58 exit $RETVAL