diff --git a/assets/js/admin/buttons.js b/assets/js/admin/buttons.js index 64802fb56..6c913c0b7 100644 --- a/assets/js/admin/buttons.js +++ b/assets/js/admin/buttons.js @@ -290,6 +290,9 @@ $(function () { $('#reboot-btn').on('click', function (ev) { ev.preventDefault(); + if (config.get_request.processed) { + photoboothTools.getRequest(config.get_request.server + '/reboot'); + } shellCommand('reboot'); return false; @@ -297,6 +300,9 @@ $(function () { $('#shutdown-btn').on('click', function (ev) { ev.preventDefault(); + if (config.get_request.processed) { + photoboothTools.getRequest(config.get_request.server + '/shutdown'); + } shellCommand('shutdown'); return false; diff --git a/assets/js/core.js b/assets/js/core.js index d44d48a53..9b0ee7e4a 100644 --- a/assets/js/core.js +++ b/assets/js/core.js @@ -826,6 +826,9 @@ const photoBooth = (function () { loaderMessage.append($('

').text(data.error)); } api.takingPic = false; + if (config.get_request.processed) { + photoboothTools.getRequest(config.get_request.server + '/error'); + } remoteBuzzerClient.inProgress(false); photoboothTools.console.logDev('Taking picture in progress: ' + api.takingPic); if (config.dev.reload_on_error) { diff --git a/assets/js/remotebuzzer-server.js b/assets/js/remotebuzzer-server.js index 2a4a60fa7..bb6d9ee2d 100644 --- a/assets/js/remotebuzzer-server.js +++ b/assets/js/remotebuzzer-server.js @@ -16,7 +16,7 @@ let collageInProgress = false, const SYNC_DESTINATION_DIR = 'photobooth-pic-sync'; let rotaryClkPin, rotaryDtPin; -const { execSync, spawnSync } = require('child_process'); +const { exec, execSync, spawnSync } = require('child_process'); const path = require('path'); const { pid: PID, platform: PLATFORM } = process; @@ -357,6 +357,24 @@ const requestListener = function (req, res) { log('http: GET /commands/shutdown-now'); if (config.remotebuzzer.usebuttons && config.remotebuzzer.shutdownbutton) { sendText('SHUTTING DOWN'); + + if (config.get_request.processed) { + const url = `${config.get_request.server}/shutdown`; + const curlCommand = `curl -s ${url}`; + + exec(curlCommand, (error, stdout, stderr) => { + if (error) { + log(`Error: ${error.message}`); + return; + } + if (stderr) { + log(`Stderr: ${stderr}`); + return; + } + log(`Response: ${stdout}`); + }); + } + /* Initiate system shutdown */ const cmd = 'sudo ' + config.commands.shutdown; execSync(cmd); @@ -368,6 +386,24 @@ const requestListener = function (req, res) { log('http: GET /commands/reboot-now'); if (config.remotebuzzer.usebuttons && config.remotebuzzer.rebootbutton) { sendText('REBOOTING NOW'); + + if (config.get_request.processed) { + const url = `${config.get_request.server}/reboot`; + const curlCommand = `curl -s ${url}`; + + exec(curlCommand, (error, stdout, stderr) => { + if (error) { + log(`Error: ${error.message}`); + return; + } + if (stderr) { + log(`Stderr: ${stderr}`); + return; + } + log(`Response: ${stdout}`); + }); + } + /* Initiate system shutdown */ const cmd = 'sudo ' + config.commands.reboot; execSync(cmd);