Browse Source

copy files to /etc and bash completion when installing

tags/v1.0.0
Robin Thoni 7 years ago
parent
commit
2ed367f169
1 changed files with 28 additions and 2 deletions
  1. 28
    2
      setup.py

+ 28
- 2
setup.py View File

@@ -1,7 +1,12 @@
1 1
 #! /usr/bin/env python
2 2
 from os import path
3 3
 import os
4
+
5
+import shutil
6
+import subprocess
7
+
4 8
 from setuptools import setup, find_packages
9
+from setuptools.command.install import install
5 10
 
6 11
 install_requires = [
7 12
     'argcomplete'
@@ -10,6 +15,27 @@ install_requires = [
10 15
 here = path.abspath(path.dirname(__file__))
11 16
 
12 17
 
18
+class InstallCommand(install):
19
+    def run(self):
20
+        install.run(self)
21
+        try:
22
+            if path.isdir('/etc/bash_completion.d/'):
23
+                shutil.copy('extra/bash/sitegen', '/etc/bash_completion.d/')
24
+        except Exception as e:
25
+            print(e)
26
+        try:
27
+            if not path.isdir('/etc/sitegen/'):
28
+                shutil.copytree('extra/sitegen/', '/etc/sitegen/')
29
+                os.mkdir('/etc/sitegen/hooks-enabled/')
30
+                for hook_type in ['site', 'cert']:
31
+                    os.mkdir('/etc/sitegen/hooks-enabled/%1s' % hook_type)
32
+                    for file in os.listdir('/etc/sitegen/hooks-available/%1s/' % hook_type):
33
+                        os.symlink('../../hooks-available/%1s/%2s' % (hook_type, file),
34
+                                   '/etc/sitegen/hooks-enabled/%1s/%2s' % (hook_type, file))
35
+        except Exception as e:
36
+            print(e)
37
+
38
+
13 39
 def package_files(directory):
14 40
     paths = []
15 41
     for (path, directories, filenames) in os.walk(directory):
@@ -68,7 +94,7 @@ Also provide a simpler way to request SSL certificate over certbot""",
68 94
     },
69 95
 
70 96
     data_files=[
71
-        ('/etc/bash_completion.d/', ['extra/bash/sitegen']),
97
+        ('share/sitegen/bash_completion.d/', ['extra/bash/sitegen']),
72 98
         ('share/sitegen/', ['extra/apache/sitegen.conf']),
73 99
         ('etc/sitegen/', ['extra/sitegen/sitegen.json']),
74 100
         ('etc/sitegen/hooks-available/cert/', package_files('extra/sitegen/hooks-available/cert/')),
@@ -83,6 +109,6 @@ Also provide a simpler way to request SSL certificate over certbot""",
83 109
     },
84 110
 
85 111
     cmdclass={
86
-        # 'install': PostInstallCommand,
112
+        'install': InstallCommand,
87 113
     }
88 114
 )

Loading…
Cancel
Save