Postinit scripts: where to put them?

Status
Not open for further replies.

Stranded Camel

Explorer
Joined
May 25, 2017
Messages
79
I need to run a postinit script, which I've carefully written to use only full command paths. It works perfectly when I run it manually, but when I set it to be run automatically as a postinit script, it's never run.

Now, the script is on an encrypted volume, but I've been unencrypting it as soon as possible after boot. But still, no joy.

It was then that I realized that apparently no one knows just when FreeNAS runs postinit scripts -- the manual neglects to provide this information, and much googling has shown that I'm not the only person with this question, and no one seems to know the answer. Plus, there's no option to set a delay before running such scripts (and using sleep doesn't work if the script fails to run). This is absolutely key to resolving the problem I'm facing -- if "postinit" means as soon as the system has booted up completely, for example, then an encrypted volume can never be used to host a script.

So if anyone has this information, I'd be grateful to hear.

Assuming this is a lost cause, where can I put postinit scripts so that they can be run before encrypted volumes are decrypted? It seems the USB sticks FreeNAS is installed on can't be used for this. And so I'm stuck...
 

kdragon75

Wizard
Joined
Aug 7, 2016
Messages
2,457
I would have to look through the source to see when it's called but the boot drive while not ideal would work. Make a folder in /usr/local/ and it should presist reboot though perhaps not updates.
 

Stranded Camel

Explorer
Joined
May 25, 2017
Messages
79
I would have to look through the source to see when it's called but the boot drive while not ideal would work. Make a folder in /usr/local/ and it should presist reboot though perhaps not updates.

I just tried that, but the FreeNAS script interface won't let you load anything from there -- it throws the error "The path must reside within a volume mount point".

Any other possibilities?
 

Stux

MVP
Joined
Jun 2, 2016
Messages
4,419
Well, you can have it in root's home directory, whcih is on the boot drive. Only thing you have to be aware of then is that it may get zapped by a re-install... But you could back it up to your pool.

I personally keep my scripts in a "server/scripts" dataset/directory, where I also have logs etc... but my pools aren't encrypted.
 

DrKK

FreeNAS Generalissimo
Joined
Oct 15, 2013
Messages
3,630
Well, you can have it in root's home directory, whcih is on the boot drive. Only thing you have to be aware of then is that it may get zapped by a re-install... But you could back it up to your pool.

I personally keep my scripts in a "server/scripts" dataset/directory, where I also have logs etc... but my pools aren't encrypted.
I've had a similar problem to the one the OP describes, and my pool is *NOT* encrypted. I gave up on mine because it wasn't a big deal. But, yes, I think the OP is on to something.
 

Stux

MVP
Joined
Jun 2, 2016
Messages
4,419
Now I’m curious...

....

614F38C2-3139-4BA9-8C8B-D0A9A3408956.jpeg


Post init script. Command is tank/server/scripts/start_fan_controller

With the correct permissions. Key is I needed to make an executable script. See my fan controller thread for instructions.

https://forums.freenas.org/index.php?threads/script-hybrid-cpu-hd-fan-zone-controller.46159/
 
Last edited:

Stranded Camel

Explorer
Joined
May 25, 2017
Messages
79

Stux

MVP
Joined
Jun 2, 2016
Messages
4,419
The word "executable" doesn't appear on the first page of that post at least. What do you mean by "executable script", besides the obvious +x permission?

That's what I mean, but notice I execute the script as a command, NOT as a script. I'm sure I would've tried the latter, I don't remember the details... but why would I have done it the way I did otherwise ;)
 
Status
Not open for further replies.
Top