-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpost-install.py
53 lines (41 loc) · 1.15 KB
/
post-install.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
#!/usr/bin/python
from shutil import copyfile
from subprocess import call
from os import sys
import SSSDConfig
sssd_conf = '/etc/sssd/sssd.conf'
lookup_conf = '/etc/httpd/conf.modules.d/55-lookup_identity.conf'
commands = (
['systemctl', 'restart', 'sssd'],
['setsebool', '-P', 'httpd_dbus_sssd', 'on'],
['sed', '-i', '/^#.*/s/^#//', lookup_conf],
['systemctl', 'restart', 'httpd']
)
def run(*cmd_params):
ret = 0
try:
cmd = cmd_params[0]
ret = call(cmd_params)
except Exception as e:
sys.stderr.write("Execution of " + cmd + " failed: " + str(e))
ret = -1
return ret
def configure_sssd():
copyfile(sssd_conf, sssd_conf + '.orig')
config_handle = SSSDConfig.SSSDConfig()
config_handle.import_config(sssd_conf)
try:
config_handle.new_service('ifp')
except SSSDConfig.ServiceAlreadyExists:
pass
config_handle.activate_service('ifp')
config_handle.write(sssd_conf)
def main():
configure_sssd()
for command in commands:
ret = run(*command)
if ret != 0:
return ret
return 0
if __name__ == '__main__':
exit(main())