diff --git a/wol-delemaco.sh b/wol-delemaco.sh new file mode 100644 index 0000000..fbac191 --- /dev/null +++ b/wol-delemaco.sh @@ -0,0 +1,63 @@ +#!/bin/bash + +# Configuration +SERVER="delemaco" # Server to ping +#wakeonlan b8:cb:29:a1:f3:88 +echo "Content-type: text/html" +echo +# Function to ping the server and generate HTML output +generate_html() { + 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="Offline" + color="red" + wakeonlan b8:cb:29:a1:f3:88 + fi + + # Generate HTML content + HTML_CONTENT=$(cat < + + + + + Server Status + + + +
+ Server $server is currently $status. +
+ + +EOL +) + echo "$HTML_CONTENT" +} + +# Run the function and save the output to a variable +HTML_OUTPUT=$(generate_html "$SERVER") + +# Print the HTML content +echo "$HTML_OUTPUT"