Setting up OctoPrint on TrueNAS 13 server inside iocage Jails

Where is the file you've been editing?

Mine is in /usr/local/etc/rc.d and has the following permissions:

[root@octoprint /usr/local/etc/rc.d]$ ls -l octoprint
-rwxr-xr-x  1 root  wheel  1955 Dec 18 18:38 octoprint

lol, its in the folder its stating it isnt, I've just copied the file from where it says it isn't into /usr/local/etc/rc.d/ folder and its gone back to the message:

root@OctoPrint:/usr/local/etc/rc.d # service octoprint restart
/etc/rc.d/octoprint: WARNING: $octoprint_enable is not set properly - see rc.conf(5).
Cannot 'restart' octoprint. Set octoprint_enable to YES in /etc/rc.conf or use 'onerestart' instead of 'restart'.
root@OctoPrint:/usr/local/etc/rc.d #

Dont you just linux lol

What happens if you do as it suggests:

service octoprint onestart

And can you show the output of ls -l in the /usr/local/etc/rc.d folder?

I've just deleted the OctoPrint file from that folder and restarted the jail.

Heres the details of the octoprint file from the /etc/rc.d/ folder

-rwxr-xr-x 1 root wheel 427 Jan 16 17:24 octoprint

Using the 'service octoprint onestart' or onestatus or onerestart all work, but not from the menu part of octoprint and if I install a plugin I have to restart the service from within putty or the truenas shell

Yes, I haven't been able to get service restart to work from the Octoprint menu - but for me, it's a small nuisance since normally, I'm not needing to restart it after it's all setup.

Maybe there was a conflict with the two rc scripts - if onestart works, then your service is defined - what about restart at the command line?

service octoprint onerestart
service octoprint onestatus

both work fine. I was mainly looking at when updates come through as that requires the restart command but I may just go through putty for that.

Well I think I’ve solved my issues, I did have a usb pci card pass through to Ubuntu where I had octoprint installed which is why octoprint in the jail couldn’t see the printer. But after I disabled that passthrough and reinstalled a brand new jail and then installed everything from the guide it’s now all working, well except the menu part which will turn octoprint off but won’t restart it even with the onerestart command. To restart octoprint I have to login to the jail and use the service command that way, but it does seem rare to have to reboot it after I’ve got everything installed.

For those interested, after setting OctoPrint up I installed all the plugins I normally use and one was causing issues PrintTimeGenius, as it was trying to find a marlin calculator for the OS which there wasn’t one. But with the help of the creator of the plug-in I’ve made a calculator for freebsd (TrueNas) and shared it with the creator.

Did you manage to solve the issue?I'd like to add a usb webcam too. Thanks!

From what I've read its all to do with the permissions within freebsd. Unfortunately I've been unable to get any webcam working following all different guides even those from freebsd.

Well I’ve gone a funny way about it, but I’ve got a webcam working on octoprint.

For what I got working I made a Ubuntu VM as I needed it for a CCTV program and from there I was able to get a feed from that program to feed into Octoprint. The program I’m using is AgentDvr which allows a MJPG feed in the format of:

192.168.0.2/video.mjpg?oids=1&size=1280x720

The ‘oids=1’ is the camera feed of which camera you want to appear. So if you have for example 5 cameras and your printer camera is on feed 5 you’d change it to ‘oids=5’

Hope this helps others.

Guide updated to work with python3 and TrueNAS 12, i would try to make a webcam work within the jail but i don't have an available one in the moment.

@Jemison Using this script...does it allow the OctoPrint restart menu to function as it should? I'd prefer not to have to log into TrueNAS everytime I update a plugin or make some other simple change in OctoPrint. Could very well be times where I need to restart the jail but I'd prefer that to be minimal. Thank you.

If you follow the guide carefully, there are commands to restart octoprint and they work within FreeBSD just fine.
Reply if you need further help.

Hi @MarkD

I never got restart to work successfully - maybe I was just doing something wrong. In any case, I stumbled upon the suggestion @puterboy made here to add > /dev/null and now it works like a charm.


This, for me, simply always worked. ¯_(ツ)_/¯

Hi all

Very much a newbie here, never really coded anything outside of VBA before, but these instructions have been very useful so far.

I have got to the following section in the instructions:

Silly question, but how do I manually start the octoprint server? Using ./OctoPrint/bin/octoprint serve appears as if it's working but then gives me an error "You should not run OctoPrint as root!"

Well, that's fine, but how do I run it otherwise?

Create a second user and switch / login with it.
you could run it with octoprint serve --iknowwhatimdoing.
but (no offense) you don't know what you're doing so run it with a non root user.

Hi, thanks for your response.
Sorry for yet another silly question - but do you mean login to the GUI with the second user? I thought you could only login as root?
And no offence taken, you are absolutely correct - I have no idea what I'm doing! This is just an old PC that I set up as a file server, this is the first time I'm venturing into anything more exotic.

no it also works with a user without any special permissions.

I just tested it to make sure it works, but it requires some additional steps.

I'll try to add them to the guide soon.

What I did:
logged in via webshell in the freenas webgui
enabled ssd
added user oprint
installed packages from the guide

logged in via ssh with user oprint
installed octoprint
started octoprint
checked which port was listed in the octoprint webui (in my case it was /dev/cuaU0)

added chown oprint /dev/cuaU0 to /etc/rc.local
restarted the jail via freenas webui

logged back in via ssh with user oprint
started octoprint again

opened octoprint webui again
connected to /dev/cuaU0
works

Bildschirmfoto vom 2022-09-03 16-29-37