Saturday, December 03, 2016

Creating Script to Run on Boot for OpenWRT (Chaos Calmer) - kerem izzet atam

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 shitty tutorial wont 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 red parts are personal shit, so put your personal own file names and commands according to your configuration :

1 - create script file under "/etc/init.d/" I named my script start-shit.sh :

root@OpenWrt:/# vim /etc/init.d/start-shit.sh

2- 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 fuck up with other init scripts
START=100


USE_PROCD=1

start_service() {
  procd_open_instance
  procd_set_param command /target/to/your/shitty/command -some -shit -here
}


3- Give execute permission to your script :

root@OpenWrt:/# chmod +x /etc/init.d/start-shit.sh

4- Enable init script with the command below. It will create symlink in /etc/rc.d directory so it makes your script run on boot :

root@OpenWrt:/# /etc/init.d/start-shit.sh enable

And done! Reboot your device and check if it works. Check links below for further reading :
https://wiki.openwrt.org/doc/techref/init.detail.cc
https://wiki.openwrt.org/inbox/procd-init-scripts
https://wiki.openwrt.org/doc/techref/procd