Plugin in octoprint sources


What is the problem?
Is it possible to add a plugin's sources directly in the octoprint sources ?
The goal is that when I install octoprint in a new Raspberry, the plugin is automatically installed and work at the first use of octoprint.

What did you already try to solve it?
I tried to put the plugin sources in the directory Octoprint/src/octoprint/plugins but it didn't work.

For now, the plugin I want to add is octolapse but I will probably have more to add in sources later

Thanks for your help

Can you please step a step back and explain the bigger picture of what you are trying to do here? Do you want to create customized images that come with some plugins already preinstalled? If so how do you plan to create those images? Adding additional plugins like Octolapse should be done during the image build process from the command line (it boils down to a simple pip install). While you can add plugins manually by copying them into ~/.octoprint/pugins, that won't work in cases of plugins with additional external plugins like e.g. Octolapse since those won't be automatically installed in such a case.

My goal is to replace the "timelapse" tab by the "octolapse" tab. This means I want to have a tab with octolapse features and the possibility to download the timelapses in the same tab (normally to download the timelapses, you have to go on the "timelapse" tab).

Then I want to install it on multiple Raspberry for other people. So I want to be able to easily add this possibility. On the raspberry, I install Raspbian and then build octoprint from source.

Maybe I just have to modify otcolapse plugin to add the possibility to download the timelapse directly in the octolapse tab and then install it via pip ?

If you want to prep an image to share, I strongly suggest to look into making your own custom build of OctoPi or any other proper image build process that doesn't consist of "flash, adjust, make a copy". Just flashing an image, doing some stuff and then creating a copy of that image is NOT the right way since it will result in the image containing various generated keys (SSH host key, SSL certificate, OctoPrint password salt and API key) that should be unique on every image, effectively causing security issues.

Well I don't make a copy of the image I modified. I only modify the source of octoprint.
On each raspberry, I flash Raspbian and then install octoprint from the sources I modified.
With this technique, I guess the keys will be different isn't it ?

They will, but in exchange for that you get an unofficial version of OctoPrint that is not supported here, probably not updateable and overall just messy.

Do it the right way, build a custom image.

So I have to add the octoprint sources that I modified in the Octopi sources and then build an image is that it ?

No, the proper way is not to modify the octoprint sources, but to write one or more plugins and include those in your custom OctoPi image. That way, if you want to update OctoPrint to a newer version, you don't have to make the modifications to the OctoPrint sources again (and again, and again), but you can just run the update from inside OctoPrint.

1 Like

I suppose one question to ask is: how many of these are you setting up? If you're only talking about two or three then you could just go through the routine per printer. If you're talking about a hundred then cloning the image once it's been setup would be a smarter choice.

No. That's never the smart choice since it will lead to the aforementioned cloned keys/certificates/salts.

I was getting to that point... but if the original poster is part of a printer manufacturer or print farm then it's pertinent. I got this down to a science for Robo; it was pretty ugly before I got there, though.