Skip to content

Instantly share code, notes, and snippets.

@envygeeks
Last active February 12, 2019 18:20
Show Gist options
  • Save envygeeks/5e1ce92c08d3fea3638b to your computer and use it in GitHub Desktop.
Save envygeeks/5e1ce92c08d3fea3638b to your computer and use it in GitHub Desktop.
Plex no sleep
#!/bin/sh
my_ips="192.168.1.2|192.168.1.3"
plex_ports="32400|32410|32412|32413|32414|32469"
ip_list=$(ipset list plex -s |sed -rn '/192\.168\.1/p' |tr "\n" "|")
ip_list=${ip_list%?}
set -e
if netstat --numeric-ports --numeric-hosts --inet -p |grep -P "tcp\s+0\s+([1-9][0-9]+)\s+(${my_ips}):(${plex_ports})\s+(${ip_list}):\d+\s+ESTABLISHED\s+\d+/Plex" >/dev/null
then exit 1
else exit 0
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment