0

I'm running this code and is working great, but whenever I enable it for running when booting, my router won't boot. When I do script start is working, when I'm doing script boot is working too. But whenever I do script enable to make it run when boot, I restart my router and my router never starts, it freezes and I need to enter failsafe mode to unbrick it.

Am I doing anything wrong? Are START and STOP variables okay?

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

START=10
STOP=15

boot() {
    airmon-ng start wlan0
    sleep 1
    start
}

start() {
        rssi mon0 &
}

stop() {
    killall -9 rssi
    exit 1
}
c4b4d4
  • 964
  • 12
  • 32
  • Is this your complete script? – Cyrus Mar 28 '16 at 20:50
  • @Cyrus It is, is just starting that rssi code – c4b4d4 Mar 28 '16 at 20:51
  • @Cyrus I will try that, you mean add `"$1"` at the really end of the bash script, right? A new line after the `}` of `stop()` – c4b4d4 Mar 28 '16 at 20:58
  • Yes. If your system boots in [System V](https://en.wikipedia.org/wiki/UNIX_System_V) style, your script is started with `/etc/init.d/your_script start`. You have no mechanism to start those functions (start, stop). Normally this is done with a `case` command. This `"$1"` is a simple version. – Cyrus Mar 28 '16 at 21:04
  • I've found https://wiki.openwrt.org/doc/techref/initscripts. The problem must have a different cause. – Cyrus Mar 28 '16 at 21:09
  • @Cyrus Yes, that's exactly where I copied the init script. It seems there is no `boot()` option and is not doing the `airmon-ng start wlan0` and it freezes for some reason because is going directly to the `start()` ? – c4b4d4 Mar 28 '16 at 21:17
  • I suggest to move your question to [Super User](http://superuser.com/tour). – Cyrus Mar 28 '16 at 21:19
  • You can try to move `airmon-ng start wlan0` and `sleep 1` to function `start()`. – Cyrus Mar 28 '16 at 21:39

1 Answers1

0

You'll need to make an .init script which starts after everything else:

#!/bin/sh /etc/rc.common
START=99

boot() {
    /usr/sbin/airmon-ng start wlan0
    if [! -d "/var/log/rssi_data"]; then
          mkdir -p /var/log/rssi_data
    fi

start() {
    service_start /usr/sbin/airodump-ng wlan0
    }

stop() {
    service_stop /usr/sbin/airodump-ng
    }

With airodump you can read (and save to /var/log/rssi_data) the rssi values. More info here: Click

Paktwis Homayun
  • 300
  • 3
  • 17