NOTE: This is an old article. Please go to the Meshlium development section in order to get the latest tutorials.

Launch a script at startup

Requeriments:

  • At least one Meshlium

If we need to get an script executed at startup, copy the script to /etc/init.d and configure rc levels. A easy example will introduce you how to get this done.



Copy the script to /etc/init.d and make it executable.
~$ cp myscript.sh /etc/init.d
~$ chmod +x /etc/init.d/myscript.sh

Configure rc to launch the script at startup
~$ update-rc.d myscript.sh defaults



Now each time the sistem starts, myscript.sh will be executed.

Some tips you should know:



Never use sleep within a script that will be executed at startup. That will block meshlium until script ends.

If there is an action that will last for long move it to a non startup script and call it from the startup script in a background call, or Meshlium will get blocked until script ends.

# Background call
other_script.sh &



Allways test well the startup scripts before moving it to /etc/init.d and configure update-rc.d. A bad script can crash Meshlium's system.

Never use a script you don't know what is it for. There are a lot of debian tutorials, before doing something in Meshlium, you should know what you are doing and test it in a debian machine if possible.


© Libelium Comunicaciones Distribuidas S.L.

| Terms of use