Sujet : Re: Simple way for web to execute root shell script.
De : tnp (at) *nospam* invalid.invalid (The Natural Philosopher)
Groupes : comp.sys.raspberry-piDate : 29. May 2025, 12:20:25
Autres entêtes
Organisation : A little, after lunch
Message-ID : <1019ftp$3qn0v$4@dont-email.me>
References : 1 2
User-Agent : Mozilla Thunderbird
On 29/05/2025 10:04, Michael Schwingen wrote:
On 2025-05-23, The Natural Philosopher <tnp@invalid.invalid> wrote:
I have a shell script that monitors hardware stuff - it needs to run as
root and be called by Apache as user www.
>
Bookworm linux on a Pi4.
https://github.com/OliveTin/OliveTin
might be worth a look. I only had a short look and have no own experience
yet.
Intersting. In the end I added this to /etc/sudoers
#allow www to access to hwinfo.sh
www-data ALL = (ALL) NOPASSWD: /usr/local/scripts/hwinfo.sh
and then invoking
#!/bin/sh
echo "content-type:text/html"
echo
sudo /usr/local/scripts/hwinfo.sh
from a script in /usr/lib/cgi-bin...
Apache and firefox seem happy enough and I can AJAX that from the browser to get uptodate info.
-- There is nothing a fleet of dispatchable nuclear power plants cannot do that cannot be done worse and more expensively and with higher carbon emissions and more adverse environmental impact by adding intermittent renewable energy.