Zachary Kotlarek 10 年 前
親
コミット
24d58b28a0
2 ファイル変更、30 行追加、0 行削除
  1. 6 0
      wol/wol-game.sh
  2. 24 0
      wol/wol.sh

+ 6 - 0
wol/wol-game.sh

@@ -0,0 +1,6 @@
+#!/bin/bash
+if [ -e ~/.bashrc ]; then
+	source ~/.bashrc
+fi
+
+exec wol.sh d8:cb:8a:9c:de:56 172.19.1.255

+ 24 - 0
wol/wol.sh

@@ -0,0 +1,24 @@
+#!/bin/bash
+
+# We need the target MAC and broadcast addresses
+ETHER="${1}"
+BCAST="${2}"
+if [ -z "${ETHER}" ] || [ -z "${BCAST}" ]; then
+	echo "Usage: ${0} MAC broadcast" 1>&2
+	exit 1
+fi
+
+# UDP needs a port
+PORT=7
+
+# Construct the packet
+RAW="`echo "${ETHER}" | sed 's/://g'`"
+PACKET="FFFFFFFFFFFF"
+i=0
+while [ $i -lt 16 ]; do
+	PACKET="${PACKET}${RAW}"
+	i=$(( $i + 1 ))
+done
+
+# Send with socat
+echo "${PACKET}" | xxd -r -p | socat - "UDP-DATAGRAM:${BCAST}:${PORT},broadcast"