initial BLIT commit

This commit is contained in:
Ruzicka Pavel 2016-09-16 03:03:49 +02:00
parent 7c2356fe80
commit 5130a2ab11
24 changed files with 900 additions and 0 deletions

25
NeNe-discovery/README.md Normal file
View file

@ -0,0 +1,25 @@
=== Instalation ===
cp notify-arp-neighbours.sh /usr/local/sbin/
chmod 755 /usr/local/sbin/notify-arp-neighbours.sh
cp netiface-default.py /usr/local/bin/
chmod 755 /usr/local/bin/netiface-default.py
cp notify-send-as-root-MSG-permanent.sh /usr/local/bin/
chmod 755 /usr/local/bin/notify-send-as-root-MSG-permanent.sh
# change value of NOTIFY_USER variable to username of the user to send notification to
editor /usr/local/bin/notify-send-as-root-MSG-permanent.sh
cp dbus-find-session.sh /usr/local/bin/
chmod 755 /usr/local/bin/dbus-find-session.sh
# install arp-scan
apt-get install arp-scan
cp arp-localnet.sh /usr/local/bin/
chmod 755 /usr/local/bin/arp-localnet.sh
cp notify-arp-neighbours /etc/network/if-up.d/
# reconnect your network and you should receive and notification about your network neighbours

5
NeNe-discovery/arp-localnet.sh Executable file
View file

@ -0,0 +1,5 @@
#!/bin/bash
IFACE_DEFAULT="$(/usr/local/bin/netiface-default.py)"
/usr/bin/arp-scan --interface=${IFACE_DEFAULT} --localnet

View file

@ -0,0 +1,10 @@
#!/bin/bash
USER_DBUS_PROCESS_NAME="gconfd-2"
export NOTIFY_SEND_BIN="/usr/bin/notify-send"
# get pid of user dbus process
DBUS_PID="$(ps ax | grep $USER_DBUS_PROCESS_NAME | grep -v grep | awk '{ print $1 }')"
# get DBUS_SESSION_BUS_ADDRESS variable
export DBUS_SESSION="$(grep -z DBUS_SESSION_BUS_ADDRESS /proc/$DBUS_PID/environ | sed -e s/DBUS_SESSION_BUS_ADDRESS=//)"

View file

@ -0,0 +1,7 @@
#!/usr/bin/python
import sys
import netifaces as ni
gw_iface = ni.gateways()['default'][ni.AF_INET][1]
print gw_iface

View file

@ -0,0 +1,4 @@
#!/bin/bash -x
#echo "START: $(date)" >> /tmp/nei
/usr/local/sbin/notify-arp-neighbours.sh
#echo "STOP: $(date)" >> /tmp/nei

View file

@ -0,0 +1,6 @@
#!/bin/bash
#. /usr/local/bin/dbus-find-session.sh
#/usr/bin/notify-send -t 0 "$(/usr/local/bin/arp-localnet.sh)"
/usr/local/bin/notify-send-as-root-MSG-permanent.sh LocalNet "$(/usr/local/bin/arp-localnet.sh)"

View file

@ -0,0 +1,23 @@
#!/bin/bash -x
#
# This script shows how to send a libnotify message
# to a specific user.
#
# It looks for a process that was started by the user and is connected to dbus.
# process to determine DBUS_SESSION_BUS_ADDRESS
NOTIFY_USER=ruza
TIME="$(date +%H:%M:%S)"
NOTIFY_SEND_BIN="/usr/bin/notify-send"
#PARAMS="$3"
. /usr/local/bin/dbus-find-session.sh
#TITLE="$(echo $1|tr -d \')"
#MESSAGE="$(echo $2|tr -d \')"
TITLE="$1"
MESSAGE="$2"
# send notify
DBUS_SESSION_BUS_ADDRESS=$DBUS_SESSION su -s /bin/bash -c "$NOTIFY_SEND_BIN -t 0 \"${TITLE}\" \"${MESSAGE}\"" ${NOTIFY_USER}
#/usr/bin/logger "${NOTIFY_USER} notified: ${TITLE}: ${MESSAGE}"