Initial commit

This commit is contained in:
Mike Cifelli 2021-06-16 16:59:16 -04:00
parent 14bd09b9fe
commit 4e7a1178d9
4 changed files with 60 additions and 0 deletions

View File

@ -1,2 +1,14 @@
# system-status # system-status
## Dependencies
```
sudo raspi-config nonint do_spi 0
sudo apt install python3-pip
sudo apt install python3-gpiozero
sudo pip3 install unicornhatmini
```
## Installation
```
sudo ./install
```

34
install Executable file
View File

@ -0,0 +1,34 @@
#! /usr/bin/env python3
import os
import sys
from string import Template
from subprocess import check_call
EXEC = 'system-status.py'
SERVICE = 'system-status.service'
SYSTEM_DIR = '/etc/systemd/system'
CURRENT_DIR = os.path.dirname(os.path.realpath(__file__))
EXEC_PATH = os.path.join(CURRENT_DIR, EXEC)
SERVICE_TEMPLATE = os.path.join(CURRENT_DIR, SERVICE)
SERVICE_FILE = os.path.join(SYSTEM_DIR, SERVICE)
PYTHON = sys.executable
EXEC_START = f'{PYTHON} {EXEC}'
with open(SERVICE_TEMPLATE) as f:
serviceTemplate = Template(f.read())
serviceFile = serviceTemplate.substitute(
workingDirectory=CURRENT_DIR,
execStart=EXEC_START
)
with open(SERVICE_FILE, 'w') as f:
f.write(serviceFile)
check_call(['systemctl', 'daemon-reload'])
check_call(['systemctl', 'enable', '--no-pager', SERVICE])
check_call(['systemctl', 'restart', '--no-pager', SERVICE])
check_call(['systemctl', 'status', '--no-pager', SERVICE])

1
system-status.py Normal file
View File

@ -0,0 +1 @@
from unicornhatmini import UnicornHATMini

13
system-status.service Normal file
View File

@ -0,0 +1,13 @@
[Unit]
Description=System Status Service
After=multi.user.target
[Service]
Type=simple
WorkingDirectory=$workingDirectory
ExecStart=$execStart
Restart=on-failure
SyslogIdentifier=system-status
[Install]
WantedBy=multi-user.target