From afcd7a4182bd3847b805e673cb18c4603805efd0 Mon Sep 17 00:00:00 2001 From: Lorenzo Iovino Date: Thu, 6 Jun 2024 17:50:08 +0200 Subject: [PATCH] Update wol-delemaco.sh --- wol-delemaco.sh | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/wol-delemaco.sh b/wol-delemaco.sh index 4c5c4ab..8597a2d 100644 --- a/wol-delemaco.sh +++ b/wol-delemaco.sh @@ -1,10 +1,25 @@ #!/bin/bash +SERVER="delemaco" # Server to ping + echo "Content-type: text/html" echo # Function to ping the server and generate HTML output generate_html() { - wakeonlan b8:cb:29:a1:f3:88 + local server=$1 + + # Ping the server (send 1 packet and wait for 1 second) + ping -c 1 -W 1 "$server" > /dev/null 2>&1 + if [ $? -eq 0 ]; then + status="Online" + color="green" + else + status="Booting" + color="gray" + wakeonlan b8:cb:29:a1:f3:88 + fi + + # Generate HTML content HTML_CONTENT=$(cat < @@ -15,7 +30,7 @@ generate_html() { Server Status