Berny23 / LD-ToyPad-Emulator

Toy Pad Emulator for Lego Dimensions (Unofficial Fan Project)
https://github.com/Berny23/LD-ToyPad-Emulator
MIT License
249 stars 43 forks source link

Add button to shutdown toypad #152

Open gaspopi opened 1 year ago

gaspopi commented 1 year ago

@Berny23 thanks for a great job with this. If you allow me a suggestion, could you add a button to shutdown the toypad machine (debian)? I try with this code and work for me:

Change in /index.js // ---------------------Begin of shutdown---------------------------------------------------- // Importa el módulo 'child_process' para ejecutar comandos del sistema const { exec } = require('child_process');

// ...

// Ruta para apagar el sistema app.post('/shutdown', (request, response) => { // Ejecuta el comando para apagar el sistema exec('sudo shutdown -h now', (error, stdout, stderr) => { if (error) { console.error(Error al apagar el sistema: ${error.message}); response.status(500).send('Error al apagar el sistema'); return; } console.log(Sistema apagado: ${stdout}); response.send('El sistema se está apagando...'); }); });

// ---------------------End of shutdown----------------------------------------------------

Change in /server/index.html

Again, thanks for all! GASPOPI

VladimirKuletski commented 1 year ago

Great idea. I have to go to SSH shell to turn it off safely each time