How to use Omega2+ as spam calls blocker

|
|
Tags:  Omega2

Omega2 in it's dock

1I was looking for an ad blocker for my SIP telephone number and I found a very simple and open source program called Super simple call blocker. In this post I explain how to install it on an Omega2+ board. These instructions probably will work with OpenWRT and other OS that use OPKG packages.

Prerequisites

  • An Omega2+ board.
  • Wifi or an Ethernet adapter for the Omega2+.
  • An SD card with almost 1GB of free space.
  • The SIP parameters of your phone provider.

This howto has been tested with an Omega2+ with the expansion dock connected to the PC by serial port, and clean installation of OnionOS version v0.3.2-b244.

Also you need to set up boot from USB or SD card because the internal storage of Omega2+ is too small to fit the call blocker. Check out how to do it in Omega docs page Booting from External Storage.

Installation of Super simple call blocker

First we will get the dependencies of the call blocker software. You must install git, nodejs, and npm. Run these commands on the console to install the dependencies:

opkg update
opkg install node node-npm git git-http ca-bundle

After that proceed with installation of Super simple call blocker. Run this on the console:

git clone https://github.com/josemmo/super-simple-call-blocker.gitcd super-simple-call-blocker/
npm install

Note: The npm install command is slow and will take to complete 21 minutes aprox. Meanwhile you may want to grab a coffee 😉

Configuration of Super Simple call blocker

Create a text file in the super-simple-call-blocker folder with the name config.json. Copy the next text and replace the values with your SIP parameters:

{
    "server": "10.31.255.134",
    "port": 5070,
    "realm": "telefonica.net",
    "user": "911223344",
    "password": "911223344"
}

Now you can run Super simple call blocker with this command: node main.js -- --config config.json

Start Super Simple Call blocker automatically

To start the program automatically when the Omega2+ turns on I wrote instructions based on the Omega docs page Running a Command on Boot.

Create a text file with the name /super-simple-call-blocker/autostart.sh with this content:

#!/bin/bash
while :
do
    VOIPSERVER_ADDRESS="10.31.255.134"

    echo "Checking there's connection with $VOIPSERVER_ADDRESS..."
    while ! ping -c 1 -W 5 $VOIPSERVER_ADDRESS
    do
        echo "Server $VOIPSERVER_ADDRESS seems to be down. Next check in 10 seconds."
        sleep 10
    done
    echo "server $VOIPSERVER_ADDRESS is up. Starting Super simple call blocker..."
    node /super-simple-call-blocker/main.js -- --config /super-simple-call-blocker/config.json --log /tmp/call-blocker.txt
    echo "Something gone wrong. Rebooting super-simple-call-blocker..."
done

Execute this command to mark the file as executable: chmod +x /super-simple-call-blocker/autostart.sh

After that, open /etc/rc.local file and insert this code before the line exit 0 sh /super-simple-call-blocker/autostart.sh >> /tmp/call-blocker.txt

To check the installation is correct, reboot your Omega2+ and execute cat /tmp/call-blocker.txt. If the installation is correct, you will see something similar to this:

root@Omega-45A4:/# cat /tmp/call-blocker.txt
Checking there's connection with 10.31.255.134...
PING 10.31.255.134 (10.31.255.134): 56 data bytes
Server 10.31.255.134 seems to be down. Next check in 10 seconds.
PING 10.31.255.134 (10.31.255.134): 56 data bytes
--- 10.31.255.134 ping statistics ---
1 packets transmitted, 1 packets received, 0% packet loss
round-trip min/avg/max = 38.916/38.916/38.916 ms
server 10.31.255.134 is up. Starting Super simple call blocker...
   _____                          _____ _                 _
  / ____|                        / ____(_)               | |
 | (___  _   _ _ __   ___ _ __  | (___  _ _ __ ___  _ __ | | ___
  \___ \| | | | '_ \ / _ \ '__|  \___ \| | '_ ` _ \| '_ \| |/ _ \
  ____) | |_| | |_) |  __/ |     ____) | | | | | | | |_) | |  __/
 |_____/ \__,_| .__/ \___|_|    |_____/|_|_| |_| |_| .__/|_|\___|
        _____ | |  _ _   ____  _            _      | |
       / ____||_| | | | |  _ \| |          | |     |_|
      | |     __ _| | | | |_) | | ___   ___| | _____ _ __
      | |    / _` | | | |  _      
      | |___| (_| | | | | |_) | | (_) | (__|         
       \_____\__,_|_|_| |____/|_|\___/ \___|_|\_\___|_|   v0.0.4

[i] Now connecting . . .
[i] Phone connected! Press "q" whenever you want to quit.
root@Omega-45A4:/#

References:
1Photo under CC BY-SA 4.0 License. Original URL: Wikipedia

Author

Sergio Monedero

I am excited to share my knowledge and insights on programming and devops through this personal website. I am a lifelong learner with a passion for technology, and I enjoy staying up-to-date on the latest industry trends.

Keep in touch with Me: SergioCoder@LinkedIn | Branyac@Github