init.dでは、openWRTに起動サービスを追加できません。

init.dでは、openWRTに起動サービスを追加できません。

TP-Link TL-WA901N/ND v3にopenWrtをインストールしました。スペースが不足しているため、luciパッケージをインストールしなかったため、cliを介して作業する必要がありました。

私が達成したいのは、起動時にmon0インタフェースを作成し、そこでtcpdumpを実行することです。 /etc/init.dにファイルを作成し、名前をmonitorとして指定しました。監視ファイルには次の内容が含まれています。

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

#to start after /etc/init.d/network is started and stop after it stopped
START=99
STOP=1

start(){
    #tried with and without the following two lines
    include /lib/network
    scan_interfaces

    iw phy phy0 interface add mon0 type monitor
    ifconfig mon0 up
    echo "mon0 is up!"
}
stop(){
    ifconfig mon0 down
    iw mon0 del
    echo "mon0 is down!"
}

次に、次のコマンドを実行します。

/etc/init.d/monitor enable

/etc/rc.d には S99monitor と K1monitor が表示されますが、再起動すると ifconfig 実行時に生成された mon0 インタフェースは見えません。

手動で起動すると動作します。

/etc/init.d/monitor start

また、上記のコマンドを/etc/rc.localに追加しようとしましたが、何も変更されませんでした。

私は何が間違っていましたか?

ベストアンサー1

追加するのを忘れたと思います。

boot(){
start
}

部分

おすすめ記事