#!/bin/bash SERVER="delemaco" # Server to ping 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="Booting" color="gray" 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"