Update wol-delemaco.sh
This commit is contained in:
parent
6203a1d76a
commit
afcd7a4182
1 changed files with 18 additions and 3 deletions
|
|
@ -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>
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue