2015-10-26 82 views
4

我創建了一個外殼,必要的功能,如 的start() 停止() 重新啓動()如何在openwrt中自動啓動應用程序?

但我的文件中,無法在開機時啓動。

我已經使用update-rc.d命令在「ubuntu」中將此文件添加到自啓動應用程序列表中。它在啓動時成功啓動。

但是在「openwrt」中我看到啓用函數。任何人都知道如何使用此功能啓用或有任何類似的命令一樣更新的rc.d在「OpenWrt的」

我在這裏有一定的參考:http://wiki.openwrt.org/doc/techref/initscripts

+0

這個問題是不是C語言,刪除'C'標籤。 – chqrlie

+0

我的錯誤...它的刪除.. – runner

回答

4

/etc/init.d/中 - 目錄將自動搜索並搜索啓動功能或START STOP。 從開機時開始。然後

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

開始位置開始

停止位置,然後停止

START=10 
STOP=15 

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

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

編輯:

在/etc/rc.common目錄中的文件進行編譯whoes將在啓動時開始。

使您的功能:/etc/init.d/your_script.sh使

在這裏你會找到有關引導http://wiki.openwrt.org/doc/techref/process.boot

+0

感謝您的迴應, 但鏈接中的問題提供的內容說同樣的事情。 我試過了..但沒有工作 – runner

6
  1. 賺更多的信息,確保您的腳本的第一行寫着:

    #!/bin/sh /etc/rc.common 
    
  2. 腳本複製到/etc/init.d/目錄

  3. 確保執行位是

    chmod +x /etc/init.d/<your script> 
    
  4. 使你的腳本

    /etc/init.d/<your script> enable 
    

    你的腳本現在應該有一個符號鏈接/etc/rc.d/

    ls -lh /etc/rc.d | grep <your script> 
    
  5. 確認您的初始化腳本啓用:

    /etc/init.d/<your script> enabled && echo on 
    

    如果這個命令返回on,那麼你都設置了。如果這個命令沒有返回任何東西,那麼你的腳本沒有啓用。下面是啓用了某個腳本的例子:

    [email protected]:~# /etc/init.d/system enabled && echo on 
    on 
    

我測試過的OpenWrt的混沌較平靜15.05這些步驟,但它應該在更早版本。祝你好運!

1

如果您只需要在系統啓動時(剛啓動後)運行命令: 編輯/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 
相關問題