Skip to content

Commit 4eeffec

Browse files
committed
Add installation docs
1 parent dff09dc commit 4eeffec

File tree

5 files changed

+45
-3
lines changed

5 files changed

+45
-3
lines changed

README.md

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,33 @@
11
# nfc-lock
22
NFC door lock
3+
4+
## Installation
5+
6+
1. `apt install python3-pip python3-systemd build-essential openssl`
7+
2. `cd /opt/`
8+
3. `git clone https://github.com/KSIUJ/nfc-lock`
9+
4. `pip3 install -r requirements.txt`
10+
6. `mkdir crt`
11+
7. `openssl req -x509 -newkey rsa:4096 -keyout cert/$(hostname).key -out cert/$(hostname).crt -nodes -days 365`
12+
5. `cp -r config-example/ config`, change relevant values in `config`
13+
6. Create `/etc/systemd/system/nfc-lock.service`, contents below
14+
7. `systemctl daemon-reload; systemctl restart nfc-lock`
15+
16+
`/etc/systemd/system/nfc-lock.service`:
17+
```
18+
[Unit]
19+
Description=NFC door lock
20+
After=multi-user.target
21+
22+
[Service]
23+
Type=simple
24+
WorkingDirectory=/opt/nfc-lock
25+
ExecStart=/usr/bin/python3 -u /opt/nfc-lock/app.py
26+
Restart=always
27+
28+
[Install]
29+
WantedBy=multi-user.target
30+
```
31+
32+
Remember to adjust `WorkingDirectory` and `ExecStart`
33+

config-example/erc_secret.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
1+
# Visible in ERC -> Clients
12
client_id = '1234567890asdgfghjklll'
2-
client_secret = '3434534534534535j3k4jhkj4h5k3jh45k3jh453'
3+
client_secret = '3434534534534535j3k4jhkj4h5k3jh45k3jh453'

config-example/main.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,37 @@
1+
# Path to NFC reader USB device
12
nfc_reader = {
23
'input_device': '/dev/input/by-id/usb-IC_Reader_IC_Reader_08FF20171101-event-kbd'
34
}
45

6+
# GPIO mappings for info LEDs. Skip if no LEDs were attached.
57
led = {
68
'green_gpio': 7,
79
'green_reversed': False,
810
'red_gpio': 11,
911
'red_reversed': False
1012
}
1113

14+
# Lock configuration
1215
lock = {
1316
'lock_gpio': 40,
1417
'opening_time': 5,
1518
'lock_reversed': True
1619
}
1720

21+
# Configuration for a server that allows to remotely open the door
1822
server = {
1923
'port': 1234,
2024
'cert_file': '/opt/nfc-lock/cert/lock.crt',
2125
'key_file': '/opt/nfc-lock/cert/lock.key'
2226
}
2327

28+
# ERC server endpoint
2429
erc = {
2530
'endpoint': 'https://ercendpoint.com'
2631
}
2732

33+
# IDs of cards that can open the door when ERC is not available
2834
hardcoded_uid = [
2935
"12345678",
3036
"90abcdef"
31-
]
37+
]

config-example/server_secret.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
1-
password = 'password'
1+
# Secret password for some undocumented api that unlocks the door
2+
password = 'password'

requirements.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
evdev~=1.4.0
2+
requests~=2.25.1
3+
urllib3~=1.26.5

0 commit comments

Comments
 (0)