Update wol-delemaco.sh

This commit is contained in:
Lorenzo Iovino 2024-06-06 17:50:08 +02:00 committed by GitHub
parent 6203a1d76a
commit afcd7a4182
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -1,10 +1,25 @@
#!/bin/bash #!/bin/bash
SERVER="delemaco" # Server to ping
echo "Content-type: text/html" echo "Content-type: text/html"
echo echo
# Function to ping the server and generate HTML output # Function to ping the server and generate HTML output
generate_html() { 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 # Generate HTML content
HTML_CONTENT=$(cat <<EOL HTML_CONTENT=$(cat <<EOL
<!DOCTYPE html> <!DOCTYPE html>
@ -15,7 +30,7 @@ generate_html() {
<title>Server Status</title> <title>Server Status</title>
<style> <style>
body { body {
background-color: black; background-color: $color;
font-family: Arial, sans-serif; font-family: Arial, sans-serif;
display: flex; display: flex;
justify-content: center; justify-content: center;
@ -31,7 +46,7 @@ generate_html() {
</head> </head>
<body> <body>
<div class="status"> <div class="status">
Server <strong>is booting. Server <strong>$server</strong> is currently $status.
</div> </div>
</body> </body>
</html> </html>