Cannot add startup service to openWRT from init.d











up vote
2
down vote

favorite












I have openWrt installed on a TP-Link TL-WA901N/ND v3. I don't have luci package installed because I don't have enough space, so I can only do thing via cli.



What I'm trying to achieve is to create a mon0 interface at startup and run tcpdump on it. I've created a file in /etc/init.d and named it monitor. The monitor file contains the following



#!/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!"
}


then I run the following



/etc/init.d/monitor enable


and in /etc/rc.d I can see S99monitor and K1monitor but when I reboot, I can't see the mon0 interface created when I do ifconfig.



This works if I manually start it with



/etc/init.d/monitor start


I've also tried adding the command above to /etc/rc.local but nothing changed.



What am I doing wrong?










share|improve this question














bumped to the homepage by Community 2 days ago


This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.















  • Did you update-rc.d monitor default? In Debian it needs special header, i don't know what in dd-wrt
    – Krzysztof Stasiak
    Jun 13 '17 at 7:08















up vote
2
down vote

favorite












I have openWrt installed on a TP-Link TL-WA901N/ND v3. I don't have luci package installed because I don't have enough space, so I can only do thing via cli.



What I'm trying to achieve is to create a mon0 interface at startup and run tcpdump on it. I've created a file in /etc/init.d and named it monitor. The monitor file contains the following



#!/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!"
}


then I run the following



/etc/init.d/monitor enable


and in /etc/rc.d I can see S99monitor and K1monitor but when I reboot, I can't see the mon0 interface created when I do ifconfig.



This works if I manually start it with



/etc/init.d/monitor start


I've also tried adding the command above to /etc/rc.local but nothing changed.



What am I doing wrong?










share|improve this question














bumped to the homepage by Community 2 days ago


This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.















  • Did you update-rc.d monitor default? In Debian it needs special header, i don't know what in dd-wrt
    – Krzysztof Stasiak
    Jun 13 '17 at 7:08













up vote
2
down vote

favorite









up vote
2
down vote

favorite











I have openWrt installed on a TP-Link TL-WA901N/ND v3. I don't have luci package installed because I don't have enough space, so I can only do thing via cli.



What I'm trying to achieve is to create a mon0 interface at startup and run tcpdump on it. I've created a file in /etc/init.d and named it monitor. The monitor file contains the following



#!/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!"
}


then I run the following



/etc/init.d/monitor enable


and in /etc/rc.d I can see S99monitor and K1monitor but when I reboot, I can't see the mon0 interface created when I do ifconfig.



This works if I manually start it with



/etc/init.d/monitor start


I've also tried adding the command above to /etc/rc.local but nothing changed.



What am I doing wrong?










share|improve this question













I have openWrt installed on a TP-Link TL-WA901N/ND v3. I don't have luci package installed because I don't have enough space, so I can only do thing via cli.



What I'm trying to achieve is to create a mon0 interface at startup and run tcpdump on it. I've created a file in /etc/init.d and named it monitor. The monitor file contains the following



#!/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!"
}


then I run the following



/etc/init.d/monitor enable


and in /etc/rc.d I can see S99monitor and K1monitor but when I reboot, I can't see the mon0 interface created when I do ifconfig.



This works if I manually start it with



/etc/init.d/monitor start


I've also tried adding the command above to /etc/rc.local but nothing changed.



What am I doing wrong?







shell shell-script boot startup openwrt






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Nov 4 '14 at 11:55









ickarsim

3616




3616





bumped to the homepage by Community 2 days ago


This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.







bumped to the homepage by Community 2 days ago


This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.














  • Did you update-rc.d monitor default? In Debian it needs special header, i don't know what in dd-wrt
    – Krzysztof Stasiak
    Jun 13 '17 at 7:08


















  • Did you update-rc.d monitor default? In Debian it needs special header, i don't know what in dd-wrt
    – Krzysztof Stasiak
    Jun 13 '17 at 7:08
















Did you update-rc.d monitor default? In Debian it needs special header, i don't know what in dd-wrt
– Krzysztof Stasiak
Jun 13 '17 at 7:08




Did you update-rc.d monitor default? In Debian it needs special header, i don't know what in dd-wrt
– Krzysztof Stasiak
Jun 13 '17 at 7:08










1 Answer
1






active

oldest

votes

















up vote
0
down vote













I guess you forgot to add the



boot(){
start
}


section






share|improve this answer



















  • 2




    can you elaborate how a boot() function would solve the problem?
    – Jeff Schaller
    Mar 30 '16 at 18:53










  • You wrote it works if you do "/etc/init.d/monitor start" but it doesn't automaticaly do it after reboot. So you need to add the boot section in /etc/init.d/monitor
    – max
    Apr 1 '16 at 11:14











Your Answer








StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "106"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f165884%2fcannot-add-startup-service-to-openwrt-from-init-d%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes








up vote
0
down vote













I guess you forgot to add the



boot(){
start
}


section






share|improve this answer



















  • 2




    can you elaborate how a boot() function would solve the problem?
    – Jeff Schaller
    Mar 30 '16 at 18:53










  • You wrote it works if you do "/etc/init.d/monitor start" but it doesn't automaticaly do it after reboot. So you need to add the boot section in /etc/init.d/monitor
    – max
    Apr 1 '16 at 11:14















up vote
0
down vote













I guess you forgot to add the



boot(){
start
}


section






share|improve this answer



















  • 2




    can you elaborate how a boot() function would solve the problem?
    – Jeff Schaller
    Mar 30 '16 at 18:53










  • You wrote it works if you do "/etc/init.d/monitor start" but it doesn't automaticaly do it after reboot. So you need to add the boot section in /etc/init.d/monitor
    – max
    Apr 1 '16 at 11:14













up vote
0
down vote










up vote
0
down vote









I guess you forgot to add the



boot(){
start
}


section






share|improve this answer














I guess you forgot to add the



boot(){
start
}


section







share|improve this answer














share|improve this answer



share|improve this answer








edited Apr 1 '16 at 11:13

























answered Mar 30 '16 at 18:16









max

11




11








  • 2




    can you elaborate how a boot() function would solve the problem?
    – Jeff Schaller
    Mar 30 '16 at 18:53










  • You wrote it works if you do "/etc/init.d/monitor start" but it doesn't automaticaly do it after reboot. So you need to add the boot section in /etc/init.d/monitor
    – max
    Apr 1 '16 at 11:14














  • 2




    can you elaborate how a boot() function would solve the problem?
    – Jeff Schaller
    Mar 30 '16 at 18:53










  • You wrote it works if you do "/etc/init.d/monitor start" but it doesn't automaticaly do it after reboot. So you need to add the boot section in /etc/init.d/monitor
    – max
    Apr 1 '16 at 11:14








2




2




can you elaborate how a boot() function would solve the problem?
– Jeff Schaller
Mar 30 '16 at 18:53




can you elaborate how a boot() function would solve the problem?
– Jeff Schaller
Mar 30 '16 at 18:53












You wrote it works if you do "/etc/init.d/monitor start" but it doesn't automaticaly do it after reboot. So you need to add the boot section in /etc/init.d/monitor
– max
Apr 1 '16 at 11:14




You wrote it works if you do "/etc/init.d/monitor start" but it doesn't automaticaly do it after reboot. So you need to add the boot section in /etc/init.d/monitor
– max
Apr 1 '16 at 11:14


















draft saved

draft discarded




















































Thanks for contributing an answer to Unix & Linux Stack Exchange!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.





Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


Please pay close attention to the following guidance:


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f165884%2fcannot-add-startup-service-to-openwrt-from-init-d%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Accessing regular linux commands in Huawei's Dopra Linux

Can't connect RFCOMM socket: Host is down

Kernel panic - not syncing: Fatal Exception in Interrupt