Let’s say I have an endpoint which returns a payload with a scheduling. Is there any way I can build a snap that performs reboot and shutdown based on that?
I have already built a snap using the solution suggested by @ogra
and I could setup a systemd timer using this in the snapcraft.yaml
command: bin/pwr_mgmt.sh
daemon: simple
plugs:
- shutdown
timer: mon-fri,04:00
However, I would like to setup systemd timer from inside the snap after making a call to the endpoint.
i fear there is no way to adjust timers yet (neither via snapctl from within the snap, nor from the outside via the snap command) … you might need to implement your own internal timer setup within the snap (i.e. via some script) …
I have taken a bit before going out with this snap because I didn’t want to publish something that was not fully tested. Now that I have used this scheduler in production environments, I feel comfortable sharing it here as well. Hopefully it might help somebody else https://snapcraft.io/powerscheduler.
I wonder if @alexmurray would be willing to grant autoconnect for the shutdown interface for this one … this is normally not lightly granted but with a description starting with:
" Shutdown scheduler for Ubuntu and Ubuntu Core systems."
and this being the only purpose of the snap, it seems to make a lot of sense …