MatthewCroughan / octobalena

Control your 3d-printer with octoprint + octoscreen via balena!
GNU General Public License v2.0
49 stars 22 forks source link

octoprint: Update API model with Octoprint API key #10

Closed richbayliss closed 4 years ago

richbayliss commented 4 years ago

When running Octoprint, the API key is pulled from the config and a corresponding Device/Service API key is updated to match.

This triggers Octodash to restart and use the newly updated key.

Change-type: patch Signed-off-by: Rich Bayliss rich@balena.io

richbayliss commented 4 years ago

@MatthewCroughan thought you might like this PR -- I notcied in your IoT handout demo that you had to do this step manually, so this little script should be useful 👍

richbayliss commented 4 years ago

This is to address issue #7

MatthewCroughan commented 4 years ago

Epic PR is epic. Will test this out now :)

MatthewCroughan commented 4 years ago

I was trying to run this on an already deployed device. This won't work because /data/ is entirely persistent and the Dockerfile is now copying the new script into the /data/ location: COPY update-balena-app.sh /update-balena-app.sh

Putting everything in /data/ is a potential flaw of the way the original base image from Nunofgs has been designed. It would be a small change, this is already talked about in the context of restoring backups in the following PR and Issue in Nunofgs' repo:

https://github.com/nunofgs/docker-octoprint/pull/35 https://github.com/nunofgs/docker-octoprint/issues/41

For example, to get around this for the time being I use PYTHONUSERBASE=/usr/local in the Dockerfile, so that plugins installed by the Dockerfile are stateless and installed in an unmanaged directory. Perhaps we should move project scripts into a /usr/src/octobalena directory which has no volume associated with it. https://github.com/MatthewCroughan/octobalena/commit/df5070f1d7f34d26f32d68c49979f7c1b7571b81

Additionally, a bit of work has to be done to base the Octoprint container on a BalenaOS image, which means this repo will not be useful outside of Balena and will be a bit larger, which is quite upsetting. I think this means that the addition of the balena labels is not actually doing anything in the current context. s this correct? For example, the label io.balena.features.balena-api: '1' is not doing anything since the Octoprint container is not based on a Balena base image?

MatthewCroughan commented 4 years ago

The aforementioned issue is not actually the cause of the problem I was having. The issue is that it was not included in the .raspberrypi3 file as well as the .template. I'll fix that, as well as put it in /usr/src/octobalena/. Then I'll submit a PR for putting all scripts in /usr/src/octobalena and make a CONTRIBUTING.md to indicate that.