Autostart on OpenWrt? init.d?

Which is the best way to autostart a program on OpenWrt?

I am pretty new to Linux and I need to autostart syncthing with an argument:

/usr/bin/syncthing -home="/mnt/sda1/.config/syncthing"

I am reading some Linux manuals that refer to using "Startup Applications", "supervisord" or "systemd", but I do not know if they are available on OpenWrt.

Maybe creating an script and placing it in init.d?

Thanks in advance.

In most cases, using Init.d is the way to go. Check out the documentation and ask specific questions if you get stuck.


Thank you, I will have a look :slight_smile:

What is the difference between standard init scripts and procd init scripts given that the wiki says for init scripts :

This only applies to traditional SysV style init scripts, See procd-init-scripts

You might edit
Will be run after most of startup scripts from /etc/init.d done.

"standard init scripts" are deprecated but still supported.

procd, the OpenWrt specific init daemon, has been the default since 2013. So, new init scripts should be written for it.

(But not all old packages have been modernized to use procd in their init scripts. And even some new packages have still been authored with the old style scripts.)

even some new packages have still been authored with the old style scripts<

May be, this is because of

  • simplicity (KISS)
  • common LINUX knowledge
  • lazyness, not to dig into the secrets of uci/ubus/procd to get rather simple functionality
  • insufficiency of uci/procd in non-standard setups

Procd init scripts allow better integration with the OpenWrt system, and offload to Procd the logic that would have otherwise be implemented in the script itself.

You can see what you can do with a one-liner in the Service Parameters

None is enforcing that rule on new community packages, so anything goes.

If you decide to not ship a procd init script in your own package, your choice does not affect the rest of the system. So as long as you don't really need it you can do without.

Many services only need to be started on boot and use static configuration (so they don't need to reload it on change), so there is no real benefit in using Procd over normal init scripts.

Stuff that is using UCI and has a Luci web interface package for configuration usually do.

This tutorial is to me kind of better than the openwrt wiki page on procd

Don’t know if it applies to our openwrt but to me was useful to understand that the


Inside the myservicename.init

(The one starting with

#!/bin/sh /etc/rc.common)

was inside the function but is obtained by parsing


UCI type config file.

I know I am dumb as the procd page explained it, but I spent ages to learn that local variable is:

A variable declared as local is one that is visible only within the block of code in which it appears. It has local "scope". In a function, a local variable has meaning only within that function block.

and reading the wiki page wasn’t enough to pick up the parsing UCI file bit. As I said Linux isn’t my bread & butter and easy and linear examples work better than a explanatory paragraph.

Is there a way to link it to the procd page ? Or to whom I should ask to have something like it at the end of the procd page as tutorial to be of help
to people like me ?

It mentions Onion Omega, which is this and as they say they are running LEDE, which is the OpenWrt release before the current 18.06.

Yes it should apply to current OpenWrt, and yes the current procd documentation is minimal.

the whole OpenWrt site is a wiki, anyone can add or edit the articles (apart from the home page and some other major pages I think).

Imho it's better to copy-paste it whole and leave a link to the original article with credits and such. A lot of sites disappear and we don't want to lose information at random.

Aand, I copy-pasted the article over (with proper formatting and all)

1 Like

Hi @bobafetthotmail,

didnt forget about my post

but problem is node.js is some java stuff people won't have on their small openwrt routers

thats why I didnt tried to create the webpage

was waiting to have something I could play with

and even a C program should be compiled for every platform

so I was thinking about a simple bash script

but then I realized openwrt doenst ships with bash but something else (I dont know bash .....something else would be a nightmare)

so I tried a simple shell (whatever kind it is) to log something to logread and then change a variable in the logged message using procd parsing system

problem is I didnt find a way to send anything to log !!! can you imagine

meanwhile I tried to log something to logread using hotplug (like I need a way to restart network when a device (wlan0 or eth1) goes up but wasnt able to do that so moved back to first try to log something to logread by hotplug)

as @jeff says I'll need a new topic about hotplug

meanwhile if anybody as a simple shell script could be used as example to procd like the node.js stuff please post it here


how many ssh sessions can I open to my ar150 router ?
(yep, sure I'll try by hands.. talk the talk.. walk the walk_)

Already linked for you, or look at the many already on your device.

Edit: Also go back and read and the archived link at the top of that page.

One less than the one that causes it to crash or otherwise misbehave.

Edit: Potentially zero, if you try to run Node.js of any complexity on a machine with 64 MB of RAM.

1 Like


Even if you forgot to address the bash like topic

By the way found node

Will have to learn openwrt for VM

I avoid bash whenever possible for system-level work. Stick with POSIX sh and you avoid a lot of unexpected behavior.

Is it so hard to comprehend that procd will start any executable or script you indicate in the

procd_set_param command /usr/bin/node "/var/mynodeservice.js"

You don't need to install Node to make a init script.

but then I realized openwrt doenst ships with bash but something else (I dont know bash .....something else would be a nightmare)

You can install bash in openwrt, you will need to call it directly to execute a script though. It is also as big as Node executable afaik.

Something like "bash"

Also, the shell used in OpenWrt is called Ash, and as long as youa re using POSIX features of Bash it should also work in OpenWrt.

anyway, I'll write a script and replace the node.js he used in the tutorial

Ok, migrated tutorial to shell script. No node is required now.

Bash and Busybox shell are similar. Write your bash scripts with #!/bin/sh first line in and it will check for features you cannot use in OpenWrt shell.
see the

You may still need to install additional commandline tools in OpenWrt. A Desktop PC Linux like Ubuntu has much more commandline tools in default install.

Check if a tool is available by writing
which tool-name
and it will answer you where this tool is, or an error if there is no such tool installed.

# which time

EDIT: now added this to wiki in the development section

1 Like

It is also possible to setup bash as default shell.
Simply edit