You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Tanner Collin 9de94414d0 Authenticate with portal to get list of cards 4 years ago
.gitignore Authenticate with portal to get list of cards 4 years ago
LICENSE Initial commit 4 years ago
README.md Refine README 4 years ago
main.py Authenticate with portal to get list of cards 4 years ago
requirements.txt Freeze requirements 4 years ago
secrets.py.example Authenticate with portal to get list of cards 4 years ago

README.md

Airlock

Door controller for scanning Protospace member cards on the front and back doors.

Setup

Ensure Pi user has read permissions to /dev/ttyACM0 (Pi user needs to be part of the dialout group).

Install dependencies:

$ sudo apt update
$ sudo apt install python3 python3-pip python-virtualenv python3-virtualenv supervisor

Clone this repo:

$ git clone https://github.com/Protospace/airlock.git
$ sudo mv airlock/ /opt/
$ cd /opt/airlock

Watchdog

For the watchdog to work, we need write access to /dev/watchdog/.

Configure /etc/udev/rules.d/60-watchdog.rules:

KERNEL=="watchdog", MODE="0666"

Main Script

Create a venv, activate it, and install:

$ virtualenv -p python3 env
$ source env/bin/activate
(env) $ pip install -r requirements.txt

Start an empty card_data.json:

(env) $ echo "{}" > card_data.json

Now you can run the script to test:

(env) $ DEBUG=true python main.py

Process management

The script is kept alive with supervisor.

Configure /etc/supervisor/conf.d/airlock.conf:

[program:airlock]
user=pi
directory=/opt/airlock
command=/opt/airlock/env/bin/python -u main.py
stopsignal=INT
autostart=true
autorestart=true
stderr_logfile=/var/log/airlock.log
stderr_logfile_maxbytes=10MB
stdout_logfile=/var/log/airlock.log
stdout_logfile_maxbytes=10MB

Script logs to /var/log/airlock.log. Remove -u from the above command when you're done testing.

License

This program is free and open-source software licensed under the MIT License. Please see the LICENSE file for details.

That means you have the right to study, change, and distribute the software and source code to anyone and for any purpose. You deserve these rights.