Energy, electricity suddenly costs a lot more
Energy prices are rising and awareness of energy consumption is increasing, as is the desire to save energy, because you are affected by it yourself.
That’s why I’m rethinking the subject and trying to reconsider what can be achieved in my household.
It would be best not to use energy in the first place and that is a point I would like to realize more often for my main computer. I have a standard PC with Linux, which I use every day for surfing and such, as well as one with Windows to play around with and a mini PC, i. i. an Intel NUC, the data heap for my LAN, it’s always running for me, just like the fridge, but it’s a low-consumption device that I’d like to afford. The NUC is headless, i.e. without a monitor and keyboard, and can only be accessed via the network - I normally only access it when I have a standard PC in operation. When I’m not playing, Windows is off, but when I’m at home, the Linux computer is running - I’ve chosen it to be off more often, even when I’m there.
So if I can migrate tasks that I normally do on the main computer to the NUC because they are not or only slightly interactive processes, I still need a way to start and stop them. A smartphone and an old tablet are available for this purpose. Of course, I can also SSH from a mobile device, but the non-haptic keyboard is annoying because the keys are so small and there is no mechanical feedback. I would like big buttons for this, which can also be easily operated on the small smartphone display with a fat thumb.
Which GUI to choose
A native Android app is out of the question because I can’t shake it out of my head. A browser would be the easier solution. However, I haven’t followed the topic of web development in its details for a long time. I knew what I wanted, a remote control for tasks that I used to do from computer to computer via SSH, in the form of a button on a smartphone. Since I don’t usually write any software for mobile devices, it should be like this to use a web browser. The mini-PC gets a web server that offers the buttons in the LAN and an evaluation of the information that flows back.
You need a website with responsive design (RWD) so that you can use it on a web browser in large format and also on a smartphone screen in a reasonable way. This is probably standard by now, but I explicitly paid attention to it when choosing a hugo theme. And of course there have to be big buttons - I chose “Bootstrap-BP hugo startpage” by Sebastian Pech - I’m already using Hugo for my website’s blog anyway. It was clear that this was my starting point.
Current security technology of the web server
The web server user is fairly unprivileged, so much so that e.g. is not allowed to use the audio device at all - he is not allowed to play web radio. In contrast to the past, the web server user is now normally not even allowed to create a file in /tmp or /var/tmp. He can, but that happens there in a security container controlled by sysmtemd. If you gain access to this (root permission required) and monitor the creation and deletion of a specific file, you can turn music on and off as a system user, because the system user is allowed to use the audio device.
First step is taken
I’m that far. I replace a call to a Startpage config target with http://IP address NUC/cgi-bin/webradio.sh
The server sided file webradio.sh has the following content:
The file is actually placed by systemd in a security container named “systemd-private-?????????????????????????????????- apache2.service-??????”
At the file level, this directory is owned by user and group root, permissions are only configured for the root user. As a result, an unprivileged system user has no access to it.
In order for us to be able to evaluate this, root must do this or an unprivileged user with sudo.
The user file web.watch.sh:
This script checks whether a specific file is created or deleted in a specific path and processes are started or terminated depending on this. This construction already works. I just call the script manually with nohup, then it runs. This can be improved even further by letting systemd manage it and also the possibility of connecting mpv to a socket for information retrieval and control options goals.
However, proof of feasibility has been provided. I can now switch the web radio on and off with my smartphone.