If you want this only during installation, it is easier to make your simple daemon install-mode: disable and use snapctl start --enable $SNAP_NAME.<service name> from the one-shot daemon…
In general though I would expect what you attempt to work (but since this relies 100% on systemd behavior, I’d check its documentation about service ordering too)
I am sorry for the confusion, its not during install but when i restart the snap, it fails:
“snap restart turftank-mk2m-sw”
error: cannot perform the following tasks:
Run service command “restart” for running services of snap “turftank-mk2m-sw” (systemctl command [start snap.turftank-mk2m-sw.check-production-test.service] failed with exit status 1: Job for snap.turftank-mk2m-sw.check-production-test.service failed.
See “systemctl status snap.turftank-mk2m-sw.check-production-test.service” and “journalctl -xe” for details.
)"
I’m asking because you could simply permanently make the simple daemon disabled and add some condition to one-shot1
that then calls snapctl start... (I.e. without --enable) every time, so one-shot would effectively become the “starter”
I tested it again now, when i installed the snap, the method you mentioned worked. But when i refreshed it did not work. Because there is snap refresh change going on, and that prevents the snapctl command to be run
Right, install-mode only applies at install (but then it is permanent) if you installed originally without install-mode it wont be changed on refreshes … similar to the install hook that only runs at first install, snapd makes a very strict distinction here between refresh and install …
I solved this by changing my one-shot service to daemon simple. Then, i wait till there are no snapd changes in progress and then i disable or enable my other services.