Difference between revisions of "Gatekeeper"

From Whitespace (Hackerspace Gent)
Jump to: navigation, search
(Connecting to the BeagleBoard)
(15 intermediate revisions by 4 users not shown)
Line 1: Line 1:
Gatekeeper is a Python script that opens a gate when calling to +32493604143. It only opens the gate for whitelisted numbers. The hardware used:
+
'''An updated version of this documentation is at [[http://www.0x20.be/Gatekeeper-Soekris]].'''
 +
 
 +
Gatekeeper is a Python script that opens a gate when calling to '''+32 (0) 484 73 95 88''' . It only opens the gate for whitelisted numbers. The hardware consists out of the [[Dooropener]] system:
  
 
* A beagle board with a Debian based distro on, kindly donated by Bert.
 
* A beagle board with a Debian based distro on, kindly donated by Bert.
 
* A remote controller for the gate connected to the beagle board. The pinout on the beagleboard towards the remote:
 
* A remote controller for the gate connected to the beagle board. The pinout on the beagleboard towards the remote:
** Pin 28: black
+
** Pin 9: white: steering, goes low (0v) when the remote needs to be activated, and high when the remote needs not be activated.
** Pin 24: white
+
** Pin 13: orange (or any other unused 1.8v pin): continuous 1.8v.
** Pin 1 (bottom): red
+
 
* A Huawei e220 GSM modem with a SIM card to perform caller ID. It is connected with the board using USB-serial.  
 
* A Huawei e220 GSM modem with a SIM card to perform caller ID. It is connected with the board using USB-serial.  
  
 
=Configuring Gatekeeper=
 
=Configuring Gatekeeper=
  
The gatekeeper script can be found at /home/ubuntu/gatekeeper/gatekeeper.py and is started at boot.
+
The gatekeeper script can be found at /opt/gatekeeper/gatekeeper.py and is started at boot. It is located on the audio server.
  
 
<pre>
 
<pre>
Line 20: Line 21:
 
</pre>
 
</pre>
  
The whitelist file can be found Whitelist syntax
+
The whitelist file uses the folowing syntax and is located at /opt/gatekeeper/whitelist. If a line with the wildcard character '*' is present the gatekeeper operates in public mode: every call from any number opens the gate.
  
 
<pre>
 
<pre>
 
098098987 name
 
098098987 name
 
080989790 other name
 
080989790 other name
 +
*
 +
</pre>
 +
 +
 +
To deamonize the python script this library is used: http://www.clapper.org/software/python/daemon/ and not the ubuntu package python-daemon, just for kicks.
 +
 +
The script is started on (re)boot using the cron facility available in ubuntu. Using sudo crontab -e you can see the current configuration. For some reason the script crashes sometimes and is restarted every 30 minutes. Root cause diagnostics needed!
 +
 +
<pre>
 +
#starts the gatekeeper script on reboot     
 +
@reboot  cd /opt/gatekeeper && python gatekeeper.py
 +
 +
#restarts the gatekeeper script every 30 min
 +
*/30 *  *  *  *    killall -v python && cd /opt/gatekeeper && python gatekeeper.py
 
</pre>
 
</pre>
  
 
=Connecting to the BeagleBoard=
 
=Connecting to the BeagleBoard=
  
The beagle board runs a debian based distro so it can be used as a general purpose server. If you want to do something with it ask for a login and sudo rights. Connecting with the board is possible using ssh. Internally it has 192.168.0.250 as IP address. Externally it is accesible with ssh on hq.0x20.be, port 2222.
+
The beagle board runs a debian based distro so it can be used as a general purpose server. If you want to do something with it ask for a login and sudo rights. Connecting with the board is possible using ssh. Internally it has 172.22.32.11 as IP address, ssh on port 22 (default ssh port). Externally it is accesible with ssh on hq.0x20.be, port 2222.
  
 
=Ideas, Feedback & Comments=
 
=Ideas, Feedback & Comments=
Line 36: Line 51:
  
 
* We can make the door opening for all people on Thursday, and only for members on the others...? @Joren: Is this pythonable?
 
* We can make the door opening for all people on Thursday, and only for members on the others...? @Joren: Is this pythonable?
** Something like that has been implemented: adding an empty line with * to the whitelist puts the script in public mode. In public mode everyone is allowed to open the gate when calling +32493604143. Removing the line with the wildcard puts the script in private mode, then only whitelisted members can open the gate.  
+
** Something like that has been implemented: adding an empty line with * to the whitelist puts the script in public mode. In public mode everyone is allowed to open the gate when calling +32484739588. Removing the line with the wildcard puts the script in private mode, then only whitelisted members can open the gate.  
* We can sound a alarm when people try to open the door but are not allowed.
+
* We can sound an alarm when people try to open the door but are not allowed.

Revision as of 20:09, 17 November 2013

An updated version of this documentation is at [[1]].

Gatekeeper is a Python script that opens a gate when calling to +32 (0) 484 73 95 88 . It only opens the gate for whitelisted numbers. The hardware consists out of the Dooropener system:

  • A beagle board with a Debian based distro on, kindly donated by Bert.
  • A remote controller for the gate connected to the beagle board. The pinout on the beagleboard towards the remote:
    • Pin 9: white: steering, goes low (0v) when the remote needs to be activated, and high when the remote needs not be activated.
    • Pin 13: orange (or any other unused 1.8v pin): continuous 1.8v.
  • A Huawei e220 GSM modem with a SIM card to perform caller ID. It is connected with the board using USB-serial.

Configuring Gatekeeper

The gatekeeper script can be found at /opt/gatekeeper/gatekeeper.py and is started at boot. It is located on the audio server.

#setup logging
LOG_FILENAME = 'gatekeeper.log'
FORMAT = "%(asctime)-12s: %(levelname)-8s - %(message)s"
logging.basicConfig(filename=LOG_FILENAME,level=logging.DEBUG,format=FORMAT)
log = logging.getLogger("GateKeeper")

The whitelist file uses the folowing syntax and is located at /opt/gatekeeper/whitelist. If a line with the wildcard character '*' is present the gatekeeper operates in public mode: every call from any number opens the gate.

098098987 name
080989790 other name
*


To deamonize the python script this library is used: http://www.clapper.org/software/python/daemon/ and not the ubuntu package python-daemon, just for kicks.

The script is started on (re)boot using the cron facility available in ubuntu. Using sudo crontab -e you can see the current configuration. For some reason the script crashes sometimes and is restarted every 30 minutes. Root cause diagnostics needed!

#starts the gatekeeper script on reboot      
@reboot  cd /opt/gatekeeper && python gatekeeper.py

#restarts the gatekeeper script every 30 min
*/30 *  *  *   *     killall -v python && cd /opt/gatekeeper && python gatekeeper.py

Connecting to the BeagleBoard

The beagle board runs a debian based distro so it can be used as a general purpose server. If you want to do something with it ask for a login and sudo rights. Connecting with the board is possible using ssh. Internally it has 172.22.32.11 as IP address, ssh on port 22 (default ssh port). Externally it is accesible with ssh on hq.0x20.be, port 2222.

Ideas, Feedback & Comments

Add your own!

  • We can make the door opening for all people on Thursday, and only for members on the others...? @Joren: Is this pythonable?
    • Something like that has been implemented: adding an empty line with * to the whitelist puts the script in public mode. In public mode everyone is allowed to open the gate when calling +32484739588. Removing the line with the wildcard puts the script in private mode, then only whitelisted members can open the gate.
  • We can sound an alarm when people try to open the door but are not allowed.