Sunday, October 25, 2015

Creating Script to Run on Startup for OpenWRT (Barrier Breaker) - kerem izzet atam

Today I wanted to create some script to mount my USB disk to my OpenWRT device on start up and run some script in it.  You might also need it if you have some huge binary to run on boot which is stored in your USB plugged in your OpenWRT device.

There is quite good source about it :
But if you are even lazy to read it, here is what work for me.

1- Create some file under /etc/init.d/ I have named mine as  ""

2- I have put my commands (in red)  under start function in my file :

#!/bin/sh /etc/rc.common
start() {
mkdir /mnt/usb
mount /dev/sda1 /mnt/usb/

START parameter defines the run order of your script among other init scripts. I have defined relatively bigger number (100) to the other scripts to make it safer (at least i hope that way). Check the source i gave above for further reading about it. You can simply look START values of other scripts with the command below :
root@OpenWrt:/# grep START= /etc/init.d/*

And you will likely to see output like this (You can see my at undermost) :

3- Give execute permission to your script :
root@OpenWrt:/# chmod +x /etc/init.d/

4- Run command below. It will create simlink in /etc/rc.d directory so it makes your script run on boot :
root@OpenWrt:/# /etc/init.d/ enable

Yeah, that is it. Hope it works.