Last active
October 13, 2023 22:06
-
-
Save ArtBIT/b6e1391c83ee47d5fdeb8194df5e0037 to your computer and use it in GitHub Desktop.
Keep TPLink Powerline alive by pinging it constantly
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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 | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.