swindmiller
Posts: 23
Joined: Mon Oct 14, 2013 1:58 pm

Basic way to shutdown via web

Mon Oct 21, 2013 12:43 pm

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

vadim
Posts: 129
Joined: Wed Sep 18, 2013 1:47 pm
Location: Nottingham

Re: Basic way to shutdown via web

Mon Oct 21, 2013 2:34 pm

make sure it is accessible from your iphone only :)

swindmiller
Posts: 23
Joined: Mon Oct 14, 2013 1:58 pm

Re: Basic way to shutdown via web

Mon Oct 21, 2013 3:21 pm

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!

swindmiller
Posts: 23
Joined: Mon Oct 14, 2013 1:58 pm

Re: Basic way to shutdown via web

Mon Oct 21, 2013 3:22 pm

vadim wrote:make sure it is accessible from your iphone only :)
How would I do that :)

swindmiller
Posts: 23
Joined: Mon Oct 14, 2013 1:58 pm

Re: Basic way to shutdown via web

Mon Oct 21, 2013 5:17 pm

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?

Nirvanak
Posts: 1
Joined: Wed Jan 15, 2014 5:50 am

Re: Basic way to shutdown via web

Wed Jan 15, 2014 5:52 am

What URL should I now use to shutdown?

Return to “Beginners”