miércoles, septiembre 26, 2018

Apagar Raspberry PI via WEB con PHP

Codigo:
sudo apt-get update && sudo apt-get install lighttpd php-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'); ?>

Opcional:
<a href="#" class="reboot"></a>
 <script>
  document.querySelector(".reboot").addEventListener('click', function(){
     $.get('shutdown.php');
 });
</script>

No hay comentarios.: