Navigation Menu

Skip to content

Commit

Permalink
added send-to, fixed wake-mac
Browse files Browse the repository at this point in the history
  • Loading branch information
VectorCell committed Aug 11, 2020
1 parent ebbc590 commit d0c34c7
Show file tree
Hide file tree
Showing 2 changed files with 54 additions and 4 deletions.
52 changes: 52 additions & 0 deletions scripts/send-to
@@ -0,0 +1,52 @@
#!/bin/bash

function usage {
echo "USAGE: send-to DEST [PORT] [SUBNET]"
echo " DEST: hostname of member of secondary network [green, tank, nissan]"
echo " PORT: port number to send TCP stream to, default 8888 [0-65535]"
echo " SUBNET: subnet of secondary network to use [1, 2]"
}

DEST=$1
PORT=$2
SUBNET=$3
if [ -z "$DEST" ]; then
usage
exit 1
fi
if [ -z "$PORT" ]; then
echo "WARNING: no port specified, assuming 8888" 1>&2
PORT=8888
fi
if [ -z "$SUBNET" ]; then
echo "WARNING: no subnet specified, assuming 1" 1>&2
SUBNET=1
fi

if [ "$DEST" == "green" ]; then
IP_1=172.16.1.1
IP_2=172.16.2.1
elif [ "$DEST" == "tank" ]; then
IP_1=172.16.1.2
IP_2=172.16.2.2
elif [ "$DEST" == "nissan" ]; then
IP_1=172.16.1.3
IP_2=172.16.2.3
else
echo "ERROR: hostname $DEST not present in secondary network"
usage
exit 1
fi

if [ $SUBNET == 1 ]; then
IP=$IP_1
elif [ $SUBNET == 2 ]; then
IP=$IP_2
else
echo "ERROR: subnet $SUBNET not present in secondary network"
usage
exit 1
fi

echo nc $IP $PORT
nc $IP $PORT
6 changes: 2 additions & 4 deletions scripts/wake-mac
Expand Up @@ -2,12 +2,10 @@

MAC=$1

IFNAME=$(ip a | grep -v "^[[:space:]]" | awk '{print $2}' | tr -d : | grep ^e)
if [ -z "$IFNAME" ]; then
IFNAME=$(ip a | grep -v "^[[:space:]]" | awk '{print $2}' | tr -d : | grep -v ^wg | grep ^w)
fi
IFNAME=$(ip r | grep ^default | awk '{print $5}')

if [ -n "$IFNAME" ]; then
echo etherwake -i $IFNAME $MAC
sudo etherwake -i $IFNAME $MAC
else
echo "unable to determine network interface"
Expand Down

0 comments on commit d0c34c7

Please sign in to comment.