How do I get a screen session to automatically start when a jail starts

DeltaEntropy

Dabbler
Joined
Mar 27, 2022
Messages
13
Hi,

I'm running TrueNAS-12.0-U8.

So I'm basically wanting irssi to automatically start when the jail starts. I'm wanting to use:

Code:
screen -d -m irssi

The above command works fine just from the CLI. I can -r into the detached screen and everything is working as expected.
So reading quite a few posts, I have created the following script:

Code:
#!/bin/sh

. /etc/rc.subr

name=irssi
rcvar=irssi_enable

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

load_rc_config $name

irssi_start()
{
    screen -d -m irssi
}

run_rc_command "$1"

I have placed it in /usr/local/etc/rc.d/ and enabled it with:
sysrc irssi_enable="YES"

I've verified that the script works by manually running it. It's just the startup that doesn't seem to be working.
I've also tried adding the "@Reboot..." line to crontab but that doesn't work either.

I'm aware that I could just setup a PRE/POST INT task, but I'm wanting it to automatically start on the jail start, instead of having to restart the whole system.

What am I doing wrong? Is my smooth brain too smooth?
 

sretalla

Powered by Neutrality
Moderator
Joined
Jan 1, 2016
Messages
9,700
Probably a path issue... rc.d doesn't run in your shell environment and hence doesn't have the path that you do in an interactive session... use the full path to the screen binary and see if that helps.
 

DeltaEntropy

Dabbler
Joined
Mar 27, 2022
Messages
13
That makes sense, didn't know that about rc.d.

So I have amended it to:

Code:
#!/bin/sh

. /etc/rc.subr

name=irssi
rcvar=irssi_enable

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

load_rc_config $name

irssi_start()
{
        /usr/local/bin/screen -d -m /usr/local/bin/irssi
}

run_rc_command "$1"

I'm now able to "service irssi start" but it starts irssi without starting the autorun scripts, when I reattached the screen session it was saying that it was the first time running irssi (it's not).

Am I using the wrong path for irssi in the script?

Still doesn't load during a jail restart, getting closer though, I think
 
Top