I have created a shell with necessary functions such as start() stop() restart()
But my file is not getting started at boot time.
I have used update-rc.d command in "ubuntu" to add this file to the list of autostart applications. And it was successfully started at boot time.
But in "openwrt" I have seen an enable function. Anyone aware of how to use this enable function or is there any similar command like update-rc.d in "openwrt"
I had some reference here : http://wiki.openwrt.org/doc/techref/initscripts
procd is the OpenWrt process management daemon written in C. It keeps track of processes started from init scripts (via ubus calls), and can suppress redundant service start/restart requests when the config/environment has not changed.
/etc/init. d contains scripts used by the System V init tools (SysVinit). This is the traditional service management package for Linux, containing the init program (the first process that is run when the kernel has finished initializing¹) as well as some infrastructure to start and stop services and configure them.
What is an init script? Keeping it simple, init script is just a shell script which always starts with shebang. It is used to start an application on boot time and stop on shutdown. It can also be used to restart and to send various other instructions to the application.
Make sure the first line of your script reads:
#!/bin/sh /etc/rc.common
Copy your script to the /etc/init.d/
directory
Make sure the execute bit is on
chmod +x /etc/init.d/<your script>
Enable your script
/etc/init.d/<your script> enable
Your script should now have a symlink in /etc/rc.d/
ls -lh /etc/rc.d | grep <your script>
Confirm your init script is enabled:
/etc/init.d/<your script> enabled && echo on
If this command returns on
, then you're all set. If this command doesn't return anything, then your script isn't enabled. Here's an example of a script that's enabled:
root@OpenWrt:~# /etc/init.d/system enabled && echo on
on
I've tested these steps on OpenWrt Chaos Calmer 15.05 but it should work on earlier versions. Good luck!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With