Shutdown via script over (W)LAN
-
Hi all!
I am just switching over to pfSense from IPcop.
I like pfSense very much already but miss a thing which I found quite handy when using IPcop:- to shutdown the cop via a script which I started over (W)LAN
To do so I just copied the code below in a .cgi and put it in "/home/httpd/html" and when I run that script via "IP:81/whatever.cgi" I was able to shutdown the system.
#!/usr/bin/perl -w use strict; use CGI::Carp qw(fatalsToBrowser); require '/var/ipcop/header.pl'; system '/usr/local/bin/ipcopdeath'; print "Content-type: text/html\n\n";
Now I want to know if there is also such comfortable(at least it is for me) to get this work on pfSense.
thanks in advance! ;D
- to shutdown the cop via a script which I started over (W)LAN
-
What does shutting down the "cop" do? Does this disable the firewall, shutdown the system, or something else?
I'm sure we can help you find a simple script written in php.
-
IP/halt.php
You could call this page with curl. -
Hi!
Thanks for the fast response.
What does shutting down the "cop" do?
Yes, It halts the system.
IP/halt.php
You could call this page with curl.This sounds quite nice already but I ve little issue with curl as I want to do the shutdown from several Systems(eg. Linux, iPhone, Mac, Windows, -curl needs to get "installed") and I was used to more or less just open that URL in whatever browser I want and it halted the system without prompting for credentials.
I am grateful for any hint ;)
-
Try the page on your device and see it it works. If not just create your own.
A simple script may look like
// Halts the system when the page is browsed // No authentication required (insecure) echo exec('shutdown -h now'); ?>
And save that to /usr/local/www/halt.php or whatever you want to name it.
-
Try the page on your device and see it it works. If not just create your own.
A simple script may look like
// Halts the system when the page is browsed // No authentication required (insecure) echo exec('shutdown -h now'); ?>
And save that to /usr/local/www/halt.php or whatever you want to name it.
Worked like a charme … ;D ;D ;D
I just replaced "shutdown -h now" with a "shutdown -p now"Thanks a lot!
-
Why shutdown -p? That just sounds unsafe.
-
Why shutdown -p? That just sounds unsafe.
With shutdown -h the system does not powerdown but with -p it does…
Why do you mean -p is unsafe? ???
-
shutdown -h does poweroff. Shutdown -h will halt the system and poweroff
shutdown -p will just power it off so it's the same as pulling the power. That's bad.
-
hmmm I am confused now….
According to the BSD manpage http://www.freebsd.org/cgi/man.cgi?query=shutdown&sektion=8-h The system is halted at the specified time.
-p The system is halted and the power is turned off (hardware support required) at the specified time.
…or do I understand something wrong here? ???
-
I know that -h will halt and shutdown because that's what I use. I guess you could experiment and see which one works best for you.
Let me know what you find out.
-
Hey!
I did some tests already and found out that with shutdown -h the system is doing a shutdown but it remains powered(on the screen you can read "press any key to reboot")
With shutdown -p system will be get "shutdowned" and powered off….
Maybe this behavior differs from system to system...?
-
Yeah, it has to differ from system to system.
I use shutdown -h all the time and it cuts the power after the shutdown process completes.Well I'm glad the php script worked for you. Take care!