How to automatically launch an application in openwrt?

I created a shell with the necessary functions, such as Start () stop () restart ()

But my file does not start at boot time.

I used the update-rc.d command in "ubuntu" to add this file to the list of startup applications. And it was launched successfully at boot time.

But in "openwrt" I saw the enable function . Does anyone know how to use this enable function, or is there a command like update-rc.d in "openwrt"

I had some link here: http://wiki.openwrt.org/doc/techref/initscripts

+4
source share
3 answers

/etc/init.d/- will be automatically read and look for the boot function or START STOP. Starts at boot time.

boot() {
        echo boot
        # commands to run on boot
}

START-Position, then to start

STOP-Position then stop

START=10 
STOP=15

start() {        
        echo start
        # commands to launch application
}                 

stop() {          
        echo stop
        # commands to kill application 
}

Edition:

In the /etc/rc.common directory files, whoes are compiled that will be launched at boot.

Enable function: /etc/init.d/your_script.sh enable

Click here for more information on downloading http://wiki.openwrt.org/doc/techref/process.boot

+4
source
  • Make sure the first line of your script reads:

    #!/bin/sh /etc/rc.common
    
  • Copy the script to the directory /etc/init.d/

  • Make sure the execution bit is on.

    chmod +x /etc/init.d/<your script>
    
  • Enable 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
    

    on, . , script . script, :

    root@OpenWrt:~# /etc/init.d/system enabled && echo on
    on
    

OpenWrt Chaos Calmer 15.05, . !

+6

( ): /etc/rc.local, .

( , ):

# Put your custom commands here that should be executed once
# the system init finished. By default this file does nothing.

.

:

# Put your custom commands here that should be executed once
# the system init finished. By default this file does nothing.

if grep -q '/dev/sdb2' /proc/swaps ; then swapoff /dev/sda2 ; fi
comgt -s /etc/config/init-script.comgt
+1

Source: https://habr.com/ru/post/1613160/


All Articles