-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsetup.py
85 lines (73 loc) · 2.76 KB
/
setup.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
import os
from setuptools import setup
from setuptools.command.bdist_egg import bdist_egg
from ConfigParser import ConfigParser
class InstallTasks(bdist_egg):
""" set up files """
def run(self):
uid = int(os.getenv('SUDO_UID', '0'))
gid = int(os.getenv('SUDO_GID', '0'))
# create directory for daemon PID file
pid_dir = '/var/run/acertive/'
if not os.path.isdir(pid_dir):
os.mkdir(pid_dir)
os.chown(pid_dir, uid, gid)
# create config file
conf_file = 'config.cfg'
data_dir = '/etc/acertive/'
if not os.path.isdir(data_dir):
os.mkdir(data_dir)
os.chown(data_dir, uid, gid)
certs_file = 'acertive_tracked.json'
# if not os.path.isfile(conf_file):
conf = ConfigParser()
conf.add_section('MAIN')
conf.set('MAIN','notifyMethod','log')
conf.set('MAIN','storedCertsFile', os.path.join(data_dir,certs_file))
conf.set('MAIN','weeklyThreshold','60')
conf.set('MAIN','dailyThreshold','14')
conf.add_section('MAIL')
conf.set('MAIL','SMTPServerName','localhost')
conf.set('MAIL','senderAddr','[email protected]')
conf.set('MAIL','notifyAddrs','')
conf.set('MAIL','useTLS', 0)
with open(os.path.join(data_dir,conf_file), 'wb') as cfile:
conf.write(cfile)
os.chown(os.path.join(data_dir,conf_file), uid, gid)
# create tracked certs file
if not os.path.exists(data_dir):
os.makedirs(data_dir)
open(os.path.join(data_dir,certs_file), 'a').close()
os.chown(os.path.join(data_dir,certs_file), uid, gid)
bdist_egg.run(self)
def read(fname):
return open(os.path.join(os.path.dirname(__file__), fname)).read()
setup(
name = "acertive",
version = "1.0",
author = "Nigel Mason",
author_email = "[email protected]",
description = ("An SSL certificate monitor for Linux"),
license = "GPLv2",
keywords = "SSL certificate expiry notify",
url = "https://github.com/ndmason1/acertive",
packages=["acertive"],
long_description=read("README.md"),
install_requires=["pyopenssl", "python-dateutil", "python-daemon", ],
classifiers=[
"Development Status :: 4 - Beta",
"Intended Audience :: System Administrators",
"License :: OSI Approved :: GNU General Public License v2 (GPLv2)",
"Operating System :: POSIX :: Linux",
"Programming Language :: Python :: 2",
"Topic :: System :: Networking :: Monitoring"
],
entry_points={
'console_scripts': [
'acertive = acertive.__main__:main'
],
},
cmdclass={
'bdist_egg': InstallTasks
}
)