-1

I defined the following script (it's called pcap):

#!/bin/sh /etc/rc.common
# Example script
# Copyright (C) 2007 OpenWrt.org
 
START=10
STOP=15
 
start() {        
        echo start
        ./delete_pcap
        # commands to launch application
}                 
 
stop() {          
        echo stop
        # commands to kill application 
}

I put this script in the /etc/init.d folder. When I do /etc/init.d/pcap start, the start function is executed and the delete_pcap (in C language, which is in the same /etc/init.d folder) program is executed correctly. Anyway, if I do /etc/init.d/pcap enable, that should execute the delete_pcap program at each reboot, the program doesn't start when the system start. I checked in the folder /etc/rc.d and I have S10pcap file (created when I do enable). So, where is the problem?

Why isn't delete_pcap executed at the system start?

user438383
  • 5,716
  • 8
  • 28
  • 43
TryToLearn
  • 29
  • 1
  • 6

1 Answers1

1

Try using new service management tools like procd:

https://openwrt.org/docs/guide-developer/procd-init-scripts

example for your app

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

APP=/usr/bin/pcap # specify the full path this is example

USE_PROCD=1
START=98 # indicates that process should start last
STOP=99

start_service() { # Override this to start your app
    procd_open_instance
    procd_set_param command "$APP"
    procd_close_instance
}

No need to override other functions like stop start restart

TotalBajor
  • 11
  • 3