hal: Branch 'master'
Danny Kukawka
dkukawka at kemper.freedesktop.org
Tue Oct 30 05:16:58 PDT 2007
tools/linux/hal-system-wol-linux | 81 +++++++++++++++++++++++++++++++++++++++
1 file changed, 81 insertions(+)
New commits:
commit adec1e7dfd0464ad067f690548319723475866a9
Author: Danny Kukawka <danny.kukawka at web.de>
Date: Tue Oct 30 13:16:52 2007 +0100
added missing file from commit eb6d5b9c
Added missing file (tools/linux/hal-system-wol-linux) from commit eb6d5b9c.
diff --git a/tools/linux/hal-system-wol-linux b/tools/linux/hal-system-wol-linux
new file mode 100644
index 0000000..36909c3
--- /dev/null
+++ b/tools/linux/hal-system-wol-linux
@@ -0,0 +1,81 @@
+#!/bin/bash
+#
+# Copyright (C) 2007 Holger Macht <holger at homac.de>
+#
+# Author: Holger Macht <holger at homac.de>
+#
+# This file is released under the GPLv2.
+#
+
+SUPPORT_FLAGS=
+IFACE="$HAL_PROP_NET_INTERFACE"
+
+wol_get_flags() {
+ SUPPORT_FLAGS=`ethtool $IFACE | awk '/Supports Wake-on:/{if ($3 ~ /g/) print $3 }'`
+ [ -n "$SUPPORT_FLAGS" ] && return 0
+ echo "org.freedesktop.Hal.Device.WakeOnLAN.NotSupported"
+ exit 1
+}
+
+wol_supported() {
+ wol_get_flags
+ [ -n "$SUPPORT_FLAGS" ] && return 0
+ return 1
+}
+
+wol_enabled() {
+ ENABLED=`ethtool $IFACE | awk '/[^s ]Wake-on:/{if ($2 ~ /g/) print $2 }'`
+ [ -n "$ENABLED" ] && return 0
+ return 1
+}
+
+wol_enable() {
+ wol_get_flags
+
+ if [ -z "$SUPPORT_FLAGS" ]; then
+ echo "No support flags set, using default: g"
+ SUPPORT_FLAGS=g
+ fi
+
+ ethtool -s $IFACE wol $SUPPORT_FLAGS
+ if [ "$?" != "0" ]; then
+ echo "error enabling wake on LAN for interface $IFACE"
+ return 1
+ fi
+}
+
+wol_disable() {
+ ethtool -s $IFACE wol d
+ if [ "$?" != "0" ]; then
+ echo "error disabling wake on LAN for interface $IFACE"
+ return 1
+ fi
+}
+
+which ethtool >/dev/null 2>&1
+if [ "$?" != "0" ]; then
+ echo "org.freedesktop.Hal.Device.WakeOnLan.NoEthtool"
+ exit 1
+fi
+
+case "`basename $0`" in
+ hal-system-wol-supported-linux)
+ wol_supported
+ ;;
+ hal-system-wol-enabled-linux)
+ wol_enabled
+ ;;
+ hal-system-wol-enable-linux)
+ if [ "$enable" = "true" ]; then
+ wol_enable
+ elif [ "$enable" = "false" ]; then
+ wol_disable
+ else
+ echo "org.freedesktop.Hal.Device.WakeOnLAN.InvalidArgument"
+ exit 1
+ fi
+ ;;
+ *) ;;
+esac
+
+exit $?
More information about the hal-commit
mailing list