Skip to content

Instantly share code, notes, and snippets.

@ArtBIT
Last active October 13, 2023 22:06
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ArtBIT/b6e1391c83ee47d5fdeb8194df5e0037 to your computer and use it in GitHub Desktop.
Save ArtBIT/b6e1391c83ee47d5fdeb8194df5e0037 to your computer and use it in GitHub Desktop.
Keep TPLink Powerline alive by pinging it constantly
#!/bin/bash
GATEWAY=`route get default | grep gateway | awk '{ print }'`
SCRIPT_COMMAND="ping $GATEWAY"
SCRIPT_PID=/tmp/pingpong.pid
case "$1" in
start)
$SCRIPT_COMMAND 1>/dev/null &
echo $!>$SCRIPT_PID
kill -SIGCONT `cat $SCRIPT_PID`
;;
stop)
kill -SIGINT `cat $SCRIPT_PID`
rm $SCRIPT_PID
;;
restart)
$0 stop
$0 start
;;
status)
if [ -e $SCRIPT_PID ]; then
echo $0 is running, pid=`cat $SCRIPT_PID`
else
echo $0 is NOT running
exit 1
fi
;;
*)
echo "Usage: $0 {start|stop|status|restart}"
esac
exit 0
@ArtBIT
Copy link
Author

ArtBIT commented Jul 11, 2017

It is a known fact that TP-Link powerline adapters randomly disconnect, which is really annoying (so don't buy them).
If you did buy them, and are experiencing this issue, you can try and fix it by constantly pinging your router, which would keep the connection alive (hopefully).
This script automates that.
Just run pingpong start on boot and you should be fine.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment