Fixing Greg's bug.

This commit is contained in:
2024-12-19 19:14:43 +02:00
parent f6d7fe310a
commit b79aa39f6d
9 changed files with 191 additions and 7 deletions

View File

@@ -0,0 +1,19 @@
> DATE: Thu 19 Dec 2024 18:35 By: konsthol@pm.me
# The magic of Wake-On-LAN
Years ago, some good friends of mine gifted me for my birthday, a Raspberry Pi 4 with 2GB of ram. It was and still is the most thoughful gift anyone has ever gotten for me. It aligns perfectly with my hobbies and I used it for a long time as a VPN server using WireGuard and I also played around with Pi-hole for a while as a network-wide ad blocker.
Eventually I became more interested in cloud computing and started self hosting many services on a VPS that I rent through MVPS. It has 4GB of ram and has currently many of the services I use in a day-to-day basis like my Gitea server, Searx, NTFY and many others. While it was definetely doable for the Raspberry Pi to host these, the 2GB of ram would not allow for every service to be run at the same time. You see, my friends were lucky to even find one because it was in the middle of the chip shortage problems.
One day as I was thinking about what kind of projects could I utilize a single Raspberry Pi for, it hit me. A simple Wake-On-LAN server. It requires almost no resources as it just needs to stay on and send out wol packages when I need it to. The Raspberry Pi is connected using Wi-Fi to the same network as my laptop. Usually if I wanted to wake my laptop up using Wake-On-LAN I would need to have it plugged with an ethernet cable with the router. However, the Raspberry Pi has an ethernet port and a cable has two ends. Which lead me to try to connect one end to the Pi and another one to the laptop. At first I begun with a simple shell script that used etherwake. A simple command-line tool that sends Wake-On-LAN Magic Packets. It worked like a charm. I had enabled Wake-On-LAN in my laptop's BIOS, it was enabled on the operating system, which I checked using ethtool and it was super easy to remotely wake my laptop up using a Termux shortcut on my phone which used ssh to connect to the Raspberry Pi and from there execute the etherwake command.
That setup was wonderful but I wanted to make it even better. It wasn't actually a Wake-On-LAN server at this point. The only service that was running on the Pi was SSH and I just used a command to wake just my laptop up. So after some research I came across Flask. With Flask I managed to make an actual server that used routes, authentication, logging rate limits and everything needed to make it robust, secure and functional. The main reason I currently prefer my project over etherwake, even though etherwake is still a great tool that follows the Unix philosophy "Do one thing and do it well", is because of it's dynamic nature. I can configure a .env file with many device's MAC addresses and have as many possible routes as the number of the devices. So for a laptop and a desktop I have LAPTOP_MAC="itsmac" and DESKTOP_MAC="itsmac" and can wake them up using http requests in the route /wol/laptop and /wol/desktop respectively.
=> /images/pic-selected-19-12-24_19-10-42.png Mascot
I would suggest anyone to take a look at my project's repo and if they find that it fits their needs, use the setupSingleBinary.sh script to grab the latest executable. The repo is over at
=> https://git.konsthol.eu/konsthol/WOL-Ly WOL-Ly
=> ..

View File

@@ -0,0 +1,93 @@
<!DOCTYPE html>
<html>
<head>
<title>Konsthol</title>
<meta charset="utf-8">
<meta name="robots" content="noindex">
<link rel="alternate" type="application/atom+xml" title="RSS Feed" href="/rss.xml">
<link rel="stylesheet" href="/css/style.css" >
<link rel="shortcut icon" type="image/png" sizes="32x32" href="/images/favicon-32x32.png">
<script>
(function(d,t) {
var BASE_URL="https://chat.konsthol.eu";
var g=d.createElement(t),s=d.getElementsByTagName(t)[0];
g.src=BASE_URL+"/packs/js/sdk.js";
g.defer = true;
g.async = true;
s.parentNode.insertBefore(g,s);
window.chatwootSettings = {
darkMode: "dark"
};
g.onload=function(){
window.chatwootSDK.run({
websiteToken: 'rYqPF7TtnospKkLhtjf5LkPy',
baseUrl: BASE_URL
})
}
})(document,"script");
</script>
</head>
<body>
<section>
<blockquote>
<p>DATE: Thu 19 Dec 2024 18:35 By: konsthol@pm.me</p>
</blockquote>
<h1 id="the-magic-of-wake-on-lan">The magic of Wake-On-LAN</h1>
<p>Years ago, some good friends of mine gifted me for my birthday, a
Raspberry Pi 4 with 2GB of ram. It was and still is the most thoughful
gift anyone has ever gotten for me. It aligns perfectly with my hobbies
and I used it for a long time as a VPN server using WireGuard and I also
played around with Pi-hole for a while as a network-wide ad blocker.</p>
<p>Eventually I became more interested in cloud computing and started
self hosting many services on a VPS that I rent through MVPS. It has 4GB
of ram and has currently many of the services I use in a day-to-day
basis like my Gitea server, Searx, NTFY and many others. While it was
definetely doable for the Raspberry Pi to host these, the 2GB of ram
would not allow for every service to be run at the same time. You see,
my friends were lucky to even find one because it was in the middle of
the chip shortage problems.</p>
<p>One day as I was thinking about what kind of projects could I utilize
a single Raspberry Pi for, it hit me. A simple Wake-On-LAN server. It
requires almost no resources as it just needs to stay on and send out
wol packages when I need it to. The Raspberry Pi is connected using
Wi-Fi to the same network as my laptop. Usually if I wanted to wake my
laptop up using Wake-On-LAN I would need to have it plugged with an
ethernet cable with the router. However, the Raspberry Pi has an
ethernet port and a cable has two ends. Which lead me to try to connect
one end to the Pi and another one to the laptop. At first I begun with a
simple shell script that used etherwake. A simple command-line tool that
sends Wake-On-LAN Magic Packets. It worked like a charm. I had enabled
Wake-On-LAN in my laptops BIOS, it was enabled on the operating system,
which I checked using ethtool and it was super easy to remotely wake my
laptop up using a Termux shortcut on my phone which used ssh to connect
to the Raspberry Pi and from there execute the etherwake command.</p>
<p>That setup was wonderful but I wanted to make it even better. It
wasnt actually a Wake-On-LAN server at this point. The only service
that was running on the Pi was SSH and I just used a command to wake
just my laptop up. So after some research I came across Flask. With
Flask I managed to make an actual server that used routes,
authentication, logging rate limits and everything needed to make it
robust, secure and functional. The main reason I currently prefer my
project over etherwake, even though etherwake is still a great tool that
follows the Unix philosophy “Do one thing and do it well”, is because of
its dynamic nature. I can configure a .env file with many devices MAC
addresses and have as many possible routes as the number of the devices.
So for a laptop and a desktop I have LAPTOP_MAC=“itsmac” and
DESKTOP_MAC=“itsmac” and can wake them up using http requests in the
route /wol/laptop and /wol/desktop respectively.</p>
<p><img
src="/images/pic-selected-19-12-24_19-10-42.png">Mascot</a><br /></p>
<p>I would suggest anyone to take a look at my projects repo and if
they find that it fits their needs, use the setupSingleBinary.sh script
to grab the latest executable. The repo is over at</p>
<p><a
href="https://git.konsthol.eu/konsthol/WOL-Ly">WOL-Ly</a><br /></p>
<p><a href="..">..</a></p>
<footer>
<a id="gemyo" href="gemini://konsthol.eu/"><img src="/images/best_viewed_on_gemini.png" /></a>
</footer>
</section>
</body>
</html>