45 lines
1.4 KiB
Python
45 lines
1.4 KiB
Python
|
import os
|
||
|
import shutil
|
||
|
import stat
|
||
|
from setuptools import setup
|
||
|
from setuptools.command.install import install
|
||
|
|
||
|
NAME = 'Sauna control'
|
||
|
VERSION = '1'
|
||
|
AUTHOR = 'Thomas Klaehn'
|
||
|
EMAIL = 'tkl@blackfinn.de'
|
||
|
PACKAGES = ['config', 'control', 'heat', 'remotectrl', 'saunacontrol']
|
||
|
REQUIRES = ['w1thermsensor', 'RPi.GPIO']
|
||
|
|
||
|
SERVICEDIR = "/lib/systemd/system"
|
||
|
DAEMON_START_SCRIPT = os.path.join(SERVICEDIR, 'saunacontrol.service')
|
||
|
|
||
|
LOGFILE = "/var/log/sauna.log"
|
||
|
|
||
|
ENTRY_POINTS = {
|
||
|
'console_scripts': [
|
||
|
'saunacontrol = saunacontrol.__main__:main'
|
||
|
]
|
||
|
}
|
||
|
|
||
|
class Install(install):
|
||
|
def run(self):
|
||
|
install.run(self)
|
||
|
os.makedirs(SERVICEDIR, exist_ok=True)
|
||
|
shutil.copyfile('saunacontrol.service', os.path.join(SERVICEDIR, DAEMON_START_SCRIPT))
|
||
|
os.chmod(DAEMON_START_SCRIPT, stat.S_IRUSR | stat.S_IWUSR | stat.S_IRGRP | stat.S_IROTH)
|
||
|
|
||
|
try:
|
||
|
open(LOGFILE, 'r')
|
||
|
except FileNotFoundError:
|
||
|
os.makedirs(os.path.dirname(LOGFILE), exist_ok=True)
|
||
|
open(LOGFILE, 'x')
|
||
|
os.chmod(LOGFILE, stat.S_IRUSR | stat.S_IWUSR | stat.S_IRGRP | stat.S_IWGRP | stat.S_IROTH | stat.S_IWOTH)
|
||
|
|
||
|
setup(name=NAME, version=VERSION, long_description=__doc__, author=AUTHOR, author_email=EMAIL,
|
||
|
packages=PACKAGES, zip_safe=False, install_requires=REQUIRES, entry_points=ENTRY_POINTS,
|
||
|
cmdclass={
|
||
|
'install': Install
|
||
|
}
|
||
|
)
|