Chaos Calmer has brand new process management daemon to handle init scripts to run on boot, named procd. You can do further reading links below if my tutorial won’t work for you. Sadly documentation about procd in OpenWRT wiki site has not been finished at the moment while I was writing this dramatic blog post… ;_;
Anyway ssh to your OpenWRT device and follow steps below. All highlighted parts are personal, so put your personal own file names and commands according to your configuration:
-
Create script file under
/etc/init.d/. I named my scriptstart-my-script.sh:root@OpenWrt:/# vim /etc/init.d/start-my-script.sh -
Copy and paste lines below to your file:
#!/bin/sh /etc/rc.common # it is run order of your script, make it high to not mess up other init scripts START=100 USE_PROCD=1 start_service() { procd_open_instance procd_set_param command /target/to/your/command -some -options -here } -
Give execute permission to your script:
root@OpenWrt:/# chmod +x /etc/init.d/start-my-script.sh -
Enable init script with the command below. It will create symlink in
/etc/rc.ddirectory so it makes your script run on boot:root@OpenWrt:/# /etc/init.d/start-my-script.sh enable
And done! Reboot your device and check if it works. Check links below for further reading:
Comments
Comments are kept in GitHub Discussions. You need a GitHub account to write one.