I have a modbus USB adapter to read power usage data. I created an init.d procd script and when starting it via web-interface or manually via cli it works fine. I just can't get it to run automatically after boot. Directly after boot the status is "inactive". I have a "boot()" function in the script which is triggered correctly. I have a logger call in there and the boot function finishes and does what it is supposed to. I also have a logger call at the top of "start_service()" which is not triggered on boot. I have a "procd_set_param netdev /dev/ttyUSB0" line in case the USB adapter is re-plugged. I also have "procd_set_param respawn 10 1 0" which is supposed to retry indefinitely.
As a workaround I also added a script in /etc/hotplug.d/tty with just debugging output, but it is only triggered on re-plugging, not boot.
I don't know how to proceed further. I found nothing in the logs indicating why the script isn't triggered and I don't understand why hotplug.d isn't triggering after boot.
post the script along with the output of ubus call system board
.
#!/bin/sh /etc/rc.common
START=99
USE_PROCD=1
PROCD_DEBUG=1
boot() {
logger "Creating strom_fifo"
[ -e /tmp/strom_fifo ] || /usr/bin/mkfifo /tmp/strom_fifo
}
start_service() {
logger "Starting strom"
procd_open_instance
procd_set_param respawn 10 1 0
procd_set_param netdev /dev/ttyUSB0
procd_set_param stderr 1
procd_set_param pidfile /var/run/strom.pid
procd_set_param command /usr/bin/lua /root/readpm.lua /dev/ttyUSB0
procd_close_instance
}
{
"kernel": "6.6.86",
"hostname": "OpenWrt",
"system": "Atheros AR9344 rev 2",
"model": "TP-Link TL-WDR3600 v1",
"board_name": "tplink,tl-wdr3600-v1",
"rootfs_type": "squashfs",
"release": {
"distribution": "OpenWrt",
"version": "24.10.1",
"revision": "r28597-0425664679",
"target": "ath79/generic",
"description": "OpenWrt 24.10.1 r28597-0425664679",
"builddate": "1744562312"
}
}
Another reason for the hotplug script I tried was to create a symlink for the correct device in case I will add another one. As I wrote the hotplug script doesn't trigger on boot either.
set -eu
logger -t hotplug $(env)
logger -t hotplug "strom ${ACTION:-} ${DEVNAME:-} ${DEVPATH:-} ${MAJOR:-} ${MINOR:-} ${SUBSYSTEM:-}"