Hi, I’m trying to create a snap which launches a daemon that gets activated upon reboot and, after sleeping for some minutes, reboots the Ubuntu Core once again.
I want to flash a custom ubuntu core image, containing the snap at issue, onto an USB drive, so as to have the daemon launched upon boot on the host machine. The goal is to make the machine reboot automatically and periodically to carry out a sort of stress test.
No, it is just example code, back when it was created netplan was not easily able to apply new configs without reboot (when the config change came from a snap) … i solely pointed to it for the few lines of the reboot code, ignore the rest
Then I installed it on my ubuntu desktop machine so as to try it before including it into an ubuntu core image. However the daemon is not able to reboot the machine, stating: “Permission denied”.
How to solve this?
Okay, thank you, now it’s working! I manually connected the snap to the shutdown interface. However I’m wandering: should I establish this connection manually also in ubuntu core? Or is it automatically connected?
you could build your own gadget (and image) and use the connections: statement in gadget.yaml for this … but that hard-requires that your app is uploaded to the store since this mechanism operates by snap ID (which you only get for officially uploaded snaps) …
beyond this, you could hack up your own (un-snapped) shell script and systemd unit to make that connection from the cmdline …