Page 1 of 1

Basic way to shutdown via web

Posted: Mon Oct 21, 2013 12:43 pm
by swindmiller
I am very new to all of this so be easy on me :D
I have my PI setup as an airplay server for my car and it works great. Right now I am ssh'ing into the Pi to run a sudo init 0 to shut it down before I turn my car off.
What I would like is a simple way for me to click a button from my iphone (I guess via a webserver running on the PI) to trigger a shutdown.

I have been searching around and found a few things but since I am such a newbie I don't quite get them :oops:

What would be the simplest way to accomplish this? It does not have to require a webserver if there is another way.

Thanks,
Scott

Re: Basic way to shutdown via web

Posted: Mon Oct 21, 2013 2:34 pm
by vadim
make sure it is accessible from your iphone only :)

Re: Basic way to shutdown via web

Posted: Mon Oct 21, 2013 3:21 pm
by swindmiller
ednl wrote:What I'd do:

Code: Select all

sudo apt-get update && sudo apt-get install lighttpd php5-cgi
sudo lighty-enable-mod fastcgi fastcgi-php
sudo service lighttpd force-reload
sudo visudo
   # Add the following line below "pi ALL etc." and exit the visudo editor:
   www-data ALL = NOPASSWD: /sbin/shutdown
sudo nano /var/www/index.html
   # Absolute minimum contents of the index.html file:
   <html><a href="shutdown.php">Shutdown NOW</a></html>
sudo nano /var/www/shutdown.php
   # Absolute minimum contents of the shutdown.php file:
   <?php system('sudo /sbin/shutdown -h now'); ?>
WOW!! Thanks so much for typing all of that out for me. It worked PERFECTLY!

Thank you very much!

Re: Basic way to shutdown via web

Posted: Mon Oct 21, 2013 3:22 pm
by swindmiller
vadim wrote:make sure it is accessible from your iphone only :)
How would I do that :)

Re: Basic way to shutdown via web

Posted: Mon Oct 21, 2013 5:17 pm
by swindmiller
ednl wrote:
swindmiller wrote:
vadim wrote:make sure it is accessible from your iphone only :)
How would I do that :)
Secure wpa2 wifi network, for example. Not sure what your setup is like now; you can ssh from iphone to rpi, because you've setup the rpi+wifi stick as an access point?
Yeah the wifi is setup as an access point and I need a password to access the Wifi...that should be enough, right?

Re: Basic way to shutdown via web

Posted: Wed Jan 15, 2014 5:52 am
by Nirvanak
What URL should I now use to shutdown?