Hi hw,
I had a similar situation in which I travelled.  I wanted to lock down the ufw 
firewall but be able to allow certain IP addresses based on the hotel IP or my 
cell service IP.  To that I developed Perl that would check my smtp account.  
The script is controlled through a cron job that runs as root.  Through email I 
can send commands to that email address that is set up for my server.  I have 
an INI file with parameters.  The script reads that INI each time.  I control 
access to not allow any other outside email from sending commands by using a 
specific email address in the INI that can send commands.  Any other email 
addresses that attempt to send commands are ignored and it sends me a report if 
this occurs. In the Perl script I was able to set up things such as allowing 
certain IPs in ufw, check disk space, run apt to update the server, and even 
reboot the server.
 
I don't know if you have access to a SMTP email server or not.  Gmail used to 
allow this type of interaction and allow log ins from scripts, but I believe 
that they have locked down security to no longer allow that.
 
I hope this helps.
 
Tim
 
 
 
-----Original Message-----
From: "hw" <h...@adminart.net>
Sent: Friday, January 12, 2024 7:16am
To: "Perl Beginners" <beginners@perl.org>
Subject: How to reboot?



Hi,

I would like to write a program (daemon) which will be automatically
started by systemd at boot which will allow me to reboot or restart my
computer through commands sent via xmpp. The xmpp part (xmpp client)
and starting that program is no problem.

But how can I reboot/restart the computer from the xmpp client? I
don't want the xmpp client to run as root all the time. I would use
something like


system('shutdown', '-r', 'now');


in the xmpp client, and that does require root privileges. To make
things more complicated, systemd will probably interfere in some ways,
and selinux also may get in the way. So how I can do that?


The background is that some idiots have decided that pressing
Ctrl+Alt+Del doesn't reboot the computer anymore but, at best,
restarts after 60 seconds if I'm logged in to a gnome session or, if
I'm not logged in --- like when the screen saver logged me out --- it
does nothing. It doesn't seem to work when I'm on the console,
either.

That totally sucks when the display remains black and doesn't come
back no matter what you do. In such cases, I still want to be able to
reboot or to shutdown the computer instead of having to hold the power
button until it turns off, and without pressing the reset button.

Preferably, I'd like to get Ctrl+Alt+Del to work again like it should,
but that's probably something we can only dream of these days :(


-- 
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/


Reply via email to