New suspend to ram plugin

Started by chunky, November 16, 2018, 11:57:14 PM

Previous topic - Next topic
I've made a simple new plugin called suspend2ram whose function as the name suggest is to put the machine under suspend to ram mode or S3. It use the already installed command acpiconf.

You can either go into suspend with the GUI (see the new option in power menu) or via the API by sending a POST http request. Exemple with curl from another network computer :


curl -XPOST -d '{}' -H "Content-Type: application/json" -k -u "your user api key":"your user api key" https://your_router_ip/api/suspend2ram/service/gosuspend


Personnaly, I use the excellent home automation server FHEM to automate tasks with other devices, so opnsense can now be easily put to sleep or wake up via wake on lan on specifics event, like presence detection in the house...

this is my first attempt to write a plugin for opnsense, so I may have missed things or there may be other ways to do this. Anyway, I thought it could serve other people, so feel free to use it if needed.

to install, put the file in your filesystem and :
pkg install os-suspend2ram-1.0.txz


It would be better if you would provide a pull request to core as this probably does not include any 3rd party code which must be installed separately. If you rename it to power, you may also add APIs for reboot and power off as well.

I don't mind posting this and it looks good, but everyone should be cautious about manually installing plugins where the source code hasn't been reviewed. If you install a package, you give it full system rights.

Happy about a PR, maybe plugins is a good starting point. :)

https://github.com/opnsense/plugins/pulls


Cheers,
Franco

Hi
I think it would have been even better if the functionnality was added to the api. It's not very hard to do but I understand you have bigger things to think about. No problem here.

Anyway, I've never used pull request or git in general, so I don't know how to proceed.