rc.d script in jail not running at startup

Anduril

Cadet
Joined
Dec 2, 2020
Messages
3
Hey there,

I have a separate jail to read the values of my solar inverters. It runs a python script originally written for raspberry, but it works well in a jail. I can start that python script in daemon mode and it will send the values to my mqtt. Now I wanted to improve, as the daemon does not autostart at reboot. So I have written a script in /usr/local/etc/rc.d/ that works when called with onestart.

Code:
#!/bin/sh

. /etc/rc.subr

name=smaemd
rcvar=smaemd_enable

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

#load_rc_Config $name

smaemd_start()
{
        /root/smaemd/sma-daemon.py start
}

smaemd_stop()
{
        /root/smaemd/sma-daemon.py stop
}

run_rc_command "$1"


I did put smaemd_enable="YES" in /etc/rc.conf, but upon service smaemd start it asked to enable in rc.conf. I even tried to add with sysrc, checked and tried again, without luck...

Code:
root@SMA-EM:~ # sysrc smaemd_enable="YES"
smaemd_enable: YES -> YES
root@SMA-EM:~ # sysrc smaemd_enable
smaemd_enable: YES
root@SMA-EM:~ # service smaemd start
/usr/local/etc/rc.d/smaemd: WARNING: $smaemd_enable is not set properly - see rc.conf(5).
Cannot 'start' smaemd. Set smaemd_enable to YES in /etc/rc.conf or use 'onestart' instead of 'start'.


Here my /etc/rc.conf

Code:
  GNU nano 5.5                      /etc/rc.conf
cron_flags="$cron_flags -J 15"

# Disable Sendmail by default
sendmail_enable="NO"
sendmail_submit_enable="NO"
sendmail_outbound_enable="NO"
sendmail_msp_queue_enable="NO"

# Run secure syslog
syslogd_flags="-c -ss"

# Enable IPv6
ipv6_activate_all_interfaces="YES"
smaemd_enable="YES"


Has anyone an idea where to look for a solution? Of course I could just login after a reboot and manually start the daemon, but that's not very handy...

Thanks in advance for your help,
Anduril
 
Top