Skip to content

Sparkz0629/wifi_presence_alerter

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Wifi Presence Alerter

A bash based script to ping a list of devices and alert of the presence changes

Getting Started

Prerequisites

The following packages should be installed already, but if they aren't, then run the following:

sudo apt-get install vim

Tmux will also be used to run the script in a session that won't be closed when disconnecting.

sudo apt-get install tmux

Global variables

You will need to set the following global variable

WIFI_PRESENCE_ALERTER_ROOT

To set this, run the following command:

sudo vim /etc/environment

and add the following

export WIFI_PRESENCE_ALERTER_ROOT={THE FULL DIRECTORY WHERE YOUR "ping_wifi_ip_address.sh" IS LOCATED}

Static IP configuration

It is suggested that you set static ip's for the devices you want to monitor. There are methods to pull these dynamically, but they are not reliable.

To set a static IP, it is suggested you google it for your router brand and model.

Configuration Files

The following configuration files are required:

device_list.lst
telegram_bot_properties.props

The contents for device_list.lst should contain the following. Multiple configurations are supported:

DeviceOwner=ip_address
DeviceOwner_2=ip_address_2

The contents for telegram_bot_properties.props should contain the following.

If multiple entries are made, the alert will be sent to each config.

BOT_API_KEY|CHAT_ID
BOT_API_KEY_2|CHAT_ID_2

Bot Details

Your api key for your bot can be retrieved from bot_father on telegram.

To find your chat_id, do the following (Note: The following should be done without a responsive bot framework hosting your bot).

  1. Create a group with your bot, or a private chat if you are not intending on using the bot in a group.
  2. Send a inline message to the bot (A message starting with "/")
  3. Run the following command:
curl -i -X GET https://api.telegram.org/bot{BOT_API_KEY}/getUpdates

You will get a response similar to the following. The chat_id is included in the "chat" section:

{
  "ok": true,
  "result": {
    "message_id": xxx,
    "from": {
      "id": xxx,
      "is_bot": true,
      "first_name": "xxx",
      "username": "xxx"
    },
    "chat": {
      "id": 12345, //This line contains the CHAT_ID
      "title": "xxx",
      "type": "xx",
      "all_members_are_administrators": true
    },
    "date": xx,
    "text": "xx"
  }
}
  1. Use this value in the config file to send messages to this particular group/private chat.

Running it in a non-ending session

You can start a new tmux session as follows:

tmux new -s1

Then run your script:

${WIFI_PRESENCE_ALERTER_ROOT}/ping_wifi_ip_address.sh

You can then detach from your session by pressing the following:

"CTRL+b" and then "d"

To re-attach to you sessionso that you can see your script run etc, run the following

tmux attach-session -t1

Remember to detach from your session, and then you can safely close your session.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages