Welcome toVigges Developer Community-Open, Learning,Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.5k views
in Technique[技术] by (71.8m points)

shell - How to auto start an application in openwrt?

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

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
  1. Make sure the first line of your script reads:

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

  3. Make sure the execute bit is on

    chmod +x /etc/init.d/<your script>
    
  4. 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>
    
  5. 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!


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to Vigges Developer Community for programmer and developer-Open, Learning and Share
...