How to remotely reboot from web-gui

Hello. Is it possible to reboot my device from the WebGUI? Sometimes it is not possible to ssh into my RPi3 in order to do this. How hard would it be for me to add a Reboot option, perhaps under the Settings/Developer menu? Is there a file I can edit to do this?

Thanks

There is an API you can call to do it, but it’s not currently exposed to the UI. You’d want to send:

POST /settings/system/actions
Accept: application/json
Content-Type: application/json
Authorization: Bearer <your-token>

{"action": "restartSystem"}

Thanks for your quick reply. Sorry to be such a newbie here, but where would I put this code? I would like to add this as a button under Settings/Developer/ along with the Remove-All-Things code you gave me earlier (which I put into a BASH script). Thanks again for that btw. Worked like a charm!

The code is the contents of an HTTP request. You could use a graphical tool like Firefox developer tools or Postman to submit a request with those headers and the JSON payload, or use a command line tool like curl in a bash script. The tricky part is finding the Bearer token to authenticate the request. You can find this by inspecting the API requests the gateway UI makes in the network panel of Firefox developer tools.

Sorry this is a bit fiddly. We do plan to add a reboot button to the gateway UI eventually, just haven’t got around to it yet. See https://github.com/mozilla-iot/gateway/issues/217

This would be a good first bug if you’re interested in contributing, we just need to figure out where to put the button!

I think it should probably either go in Settings somewhere (but not Developer settings), or be part of some kind of combined logout/shutdown/reboot option in the main menu.

Thank you for this info. I have since reconsidered the Reboot button more in favor of a Restart Gateway service button, but perhaps there is room for both. I am still learning Mozilla IoT and would really like to get more involved once I understand it better. Thanks again!

@benfrancis I’d vote in the favour of putting the restart service/reboot gateway buttons in the developer settings. It already has settings for ssh and internal logs. This would better group with those.

Reboot/Restart gateway should be a developer option otherwise, if it’s exposed in the main menu, the user might click accidently.

1 Like