From ed52755abec324164b49f6306d2cdf0b1ab69f45 Mon Sep 17 00:00:00 2001 From: Filip Rojek Date: Mon, 4 Mar 2024 02:05:55 +0100 Subject: [PATCH] First attempt --- README.md | 2 ++ main.py | 26 ++++++++++++++++++++++++++ 2 files changed, 28 insertions(+) create mode 100755 main.py diff --git a/README.md b/README.md index be41af8..9f42e91 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,4 @@ # Wake On Traffic +## Dependencies +- wakeonlan diff --git a/main.py b/main.py new file mode 100755 index 0000000..dbe9596 --- /dev/null +++ b/main.py @@ -0,0 +1,26 @@ +#!/usr/bin/python3 + +import os +import sys +from wakeonlan import send_magic_packet + +def check_status(ip): + res = os.system("ping -n -c 1 " + ip + " > /dev/null") + if res == 0: + return True + else: + return False + +def main(): + ip = "127.0.0.1" + mac = "ff-ff-ff-ff-ff-ff" + if check_status(ip): + print("System is up") + sys.exit(0) + else: + print("System is down") + print("Sending WoL magic packet to " + mac) + send_magic_packet(mac) + sys.exit(1) +main() +