Help with Jail rc.d script not executing on startup

FrankWard

Explorer
Joined
Feb 13, 2023
Messages
71
I've created a Jail with the Subsonic streamer. I've set up the script as /etc/rc.d/subsonic and set permissions with chmod 777 and chmod +x. I've added the enable command in rc.conf. When I run "/etc/rc.d/subsonic start" from the CLI it works and the web UI is accessible. However, it doe not execute the script when the jail is rebooted. Here are my scripts. Is there anything I'm missing?

/etc/rc.conf
Code:
subsonic_enable="YES"


/etc/rc.d/subsonic
Code:
#!/bin/sh

. /etc/rc.subr

name="subsonic"
rcvar="subsonic_enable"

start_cmd="${name}_start"
stop_cmd=":"

load_rc_config $name

subsonic_start()
{
echo "Running Subsonic"
/var/subsonic/subsonic.sh
}
run_rc_command "$1"



Thanks!
 
Joined
Oct 22, 2019
Messages
3,641
Installing the subsonic-standalone port or binary pkg should place the appropriate service file under:
/usr/local/etc/rc.d/

Why did you create one from scratch?

* Not available as a binary pkg
 
Last edited:

FrankWard

Explorer
Joined
Feb 13, 2023
Messages
71
I did some research before installing and came across this thread which says the plugin was not available. I did more research and saw much of the same about Subsonic not being available, so I followed the steps taken to install it manually. Please point me to the plugin version if you know where I can find it. Also, I didn't see any default service file created using the Subsonic Stand-Alone Installation.

I've been running Subsonic for years and have a lifetime license, so I wanted to port my old data into it along with the license which worked fine with my current setup. I just can't get the RC to launch the default subsonic.sh script created by the installer.

I can adopt a different solution such as crontab, etc., but I'd like to also know why this approach using RC doesn't work. If anyone can tell me what I might be doing wrong with the RC approach I'd appreciate it.
 
Last edited:

Patrick M. Hausen

Hall of Famer
Joined
Nov 25, 2013
Messages
7,776
FreeBSD package != TrueNAS plugin. But apparently subsonic is not available as a package. You could still install from ports, though:


Now to debug problems with startup scripts you can place these two lines in your rc script after the #!/bin/sh:
Code:
set -x
exec >/tmp/subsonic.log 2>&1


Then restart your jail and check that logfile.
 
Joined
Oct 22, 2019
Messages
3,641
It's available in the Ports Collection, under www/subsonic-standalone
 

Patrick M. Hausen

Hall of Famer
Joined
Nov 25, 2013
Messages
7,776
Joined
Oct 22, 2019
Messages
3,641
That's what I linked to :wink:
We were typing at the same time. I even saw an alert before clicking the "Post reply" button.

I kid you not: I thought to myself "I bet Patrick just jumped in here with more useful information than I can provide. I hope he has!" :cool:
 

Patrick M. Hausen

Hall of Famer
Joined
Nov 25, 2013
Messages
7,776
Thanks, mate :smile:
 
Joined
Oct 22, 2019
Messages
3,641
Hey I learned something new from this thread, which I wasn't familiar with before (being a FreeBSD newbie): software with a "restricted" license is not made available as a binary pkg.

(I'm not sure why, as it probably gets into the weeds of licensing, legality, and FreeBSD philosophy and packaging rules.)
 

Patrick M. Hausen

Hall of Famer
Joined
Nov 25, 2013
Messages
7,776
If the copyright holder of that piece of software explicitly forbids distribution in binary form, that is that. About their motivation one can only speculate.
 

FrankWard

Explorer
Joined
Feb 13, 2023
Messages
71
FreeBSD package != TrueNAS plugin. But apparently subsonic is not available as a package. You could still install from ports, though:


Now to debug problems with startup scripts you can place these two lines in your rc script after the #!/bin/sh:
Code:
set -x
exec >/tmp/subsonic.log 2>&1


Then restart your jail and check that logfile.

Thank you for the info!

First, if I set it up in crontab with (@Reboot sh /var/subsonic/subsonic.sh) it works fine. So, this is just my curiosity to understand how jails work a bit better.

The log shows that the RC script is working and starting Subsonic, but the process is not running, so I check another log and see (/var/subsonic/subsonic.sh: java: not found). I updated the script to the correct location of Java and it's now loading.

Can anyone explain why the Jail can't see Java in the path but the shell and crontab can?
 

Patrick M. Hausen

Hall of Famer
Joined
Nov 25, 2013
Messages
7,776
During the startup phase /usr/local/bin is not in the search path. It's good practice to call everything with full absolute paths in rc scripts, anyway.
Glad I could help.

Jails as commonly used in TrueNAS are a full virtual FreeBSD installation. That's why I am sometimes frustrated with users complaining about the lack of plugins or docs etc. It's a lightweight "virtual machine". The FreeBSD handbook applies. Case closed in my opinion.

Q: "But how do I install guacamole?"
A: Create jail, enable SSH in jail, start jail, pkg install guacamole-server; pkg install guacamole-client

That's it. Plain FreeBSD. I'm simplifying a bit, of course, but essentially there is no magic involved. Jails are brilliant.
 

FrankWard

Explorer
Joined
Feb 13, 2023
Messages
71
During the startup phase /usr/local/bin is not in the search path. It's good practice to call everything with full absolute paths in rc scripts, anyway.

Glad I could help.

Agreed. Thanks again.

*SOLVED*
 
Top