OPNsense Forum

Archive => 18.7 Legacy Series => Topic started by: chunky on November 16, 2018, 11:57:14 pm

Title: New suspend to ram plugin
Post by: chunky on November 16, 2018, 11:57:14 pm
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 :

Code: [Select]
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 :
Code: [Select]
pkg install os-suspend2ram-1.0.txz
(http://upload.dinhosting.fr/9/I/0/Clipboard01.jpg)
Title: Re: New suspend to ram plugin
Post by: fabian on November 17, 2018, 07:54:51 am
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.
Title: Re: New suspend to ram plugin
Post by: franco on November 20, 2018, 07:20:06 am
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
Title: Re: New suspend to ram plugin
Post by: chunky on November 20, 2018, 10:21:39 pm
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.