Added install script

This commit is contained in:
EpicKiwi 2023-08-01 19:17:05 +02:00
parent f1506a45f5
commit ea7097a016
Signed by: epickiwi
GPG Key ID: C4B28FD2729941CE
6 changed files with 50 additions and 5 deletions

23
install.sh Executable file
View File

@ -0,0 +1,23 @@
#!/bin/bash
set -e
rm -rfv /usr/share/zigbee-opener/
mkdir -p /usr/share/zigbee-opener/
mkdir -p /var/run/zigbee-opener/
cp -v main.py /usr/share/zigbee-opener/
cp -v settings.py /usr/share/zigbee-opener/
chmod +x /usr/share/zigbee-opener/main.py
cp -f zigbee-opener.service /etc/systemd/system/
python -m venv /usr/share/zigbee-opener/.venv/
source /usr/share/zigbee-opener/.venv/bin/activate
pip install -r requirements.txt
echo ""
echo "Installed into /usr/share/zigbee-opener/"
echo "with service zigbee-opener"
echo ""
echo "Configure in /usr/share/zigbee-opener/settings.py"

View File

@ -1,4 +1,4 @@
#!/bin/env python #!./.venv/bin/python
import zigate import zigate
from zigate import dispatcher from zigate import dispatcher
import time import time
@ -42,10 +42,11 @@ def trigger_closing():
global is_opening global is_opening
global is_closing global is_closing
if is_opening: if is_closing:
return return
is_closing = True is_closing = True
is_opening = False
for i in range(0, CLOSING_TRIGGER_DELAY): for i in range(0, CLOSING_TRIGGER_DELAY):
time.sleep(1) time.sleep(1)

View File

@ -13,5 +13,5 @@ OPENING_TRIGGER_DELAY = 30
# Delay to wait before marking room as closed # Delay to wait before marking room as closed
CLOSING_TRIGGER_DELAY = 5 CLOSING_TRIGGER_DELAY = 5
LOL_OPENED_CMD = "ln -f -s a.txt test/status.txt" LOL_OPENED_CMD = """echo "opened" > /var/run/zigbee-opener/status """
LOL_CLOSED_CMD = "ln -f -s b.txt test/status.txt" LOL_CLOSED_CMD = """echo "closed" > /var/run/zigbee-opener/status """

View File

@ -1 +1 @@
a.txt b.txt

9
uninstall.sh Executable file
View File

@ -0,0 +1,9 @@
#!/bin/bash
set -e
rm -rfv /usr/share/zigbee-opener/
rm -rfv /var/run/zigbee-opener/
rm -fv /etc/systemd/system/zigbee-opener.service
echo ""
echo "Uninstalled"

12
zigbee-opener.service Normal file
View File

@ -0,0 +1,12 @@
[Unit]
Description=Zigbee LOL opening detection system
After=network.target
[Service]
Restart=always
ExecStart=/usr/share/zigbee-opener/main.py
Type=simple
WorkingDirectory=/usr/share/zigbee-opener/
[Install]
WantedBy=multi-user.target