Changeset 2825
- Timestamp:
- Feb 23, 2017, 1:18:37 AM (8 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/server/fedora/config/etc/httpd/export-scripts-certs
r2821 r2825 2 2 3 3 import base64 4 import errno 5 import fcntl 4 6 import hashlib 5 7 import ldap 6 8 import os 9 import subprocess 7 10 import sys 8 11 import textwrap … … 98 101 yield '</VirtualHost>\n' 99 102 100 with open(os.path.join(CERTS_DIR, 'vhosts.conf.new'), 'w') as vhosts_file: 101 vhosts_file.write('# Generated by {}. Manual changes will be lost.\n\n'.format(os.path.realpath(__file__))) 102 vhosts_file.write(''.join(l for dn, vhost in vhosts for l in conf(vhost))) 103 os.rename(os.path.join(CERTS_DIR, 'vhosts.conf.new'), os.path.join(CERTS_DIR, 'vhosts.conf')) 103 with open(os.path.join(CERTS_DIR, '.lock'), 'w') as lock_file: 104 fcntl.flock(lock_file.fileno(), fcntl.LOCK_EX) 104 105 105 for filename in os.listdir(CERTS_DIR): 106 if filename.endswith('.pem') and filename not in cert_filenames: 107 os.remove(os.path.join(CERTS_DIR, filename)) 106 new_vhosts_conf = \ 107 '# Generated by {}. Manual changes will be lost.\n\n'.format(os.path.realpath(__file__)) + \ 108 ''.join(l for dn, vhost in vhosts for l in conf(vhost)) 109 110 try: 111 with open(os.path.join(CERTS_DIR, 'vhosts.conf')) as vhosts_file: 112 old_vhosts_conf = vhosts_file.read() 113 except IOError as e: 114 if e.errno == errno.ENOENT: 115 old_vhosts_conf = None 116 else: 117 raise 118 119 if old_vhosts_conf is not None and new_vhosts_conf != old_vhosts_conf: 120 with open(os.path.join(CERTS_DIR, 'vhosts.conf.new'), 'w') as new_vhosts_file: 121 new_vhosts_file.write(new_vhosts_conf) 122 os.rename(os.path.join(CERTS_DIR, 'vhosts.conf.new'), os.path.join(CERTS_DIR, 'vhosts.conf')) 123 124 configtest = subprocess.Popen(['apachectl', 'configtest'], stderr=subprocess.PIPE) 125 e = configtest.communicate()[1] 126 if configtest.returncode == 0 and e == 'Syntax OK\n': 127 subprocess.check_call(['apachectl', 'graceful']) 128 else: 129 err('apachectl configtest failed:\n' + e) 130 131 for filename in os.listdir(CERTS_DIR): 132 if filename.endswith('.pem') and filename not in cert_filenames: 133 os.remove(os.path.join(CERTS_DIR, filename)) 134 135 fcntl.flock(lock_file.fileno(), fcntl.LOCK_UN) 108 136 109 137 sys.exit(1 if error else 0)
Note: See TracChangeset
for help on using the changeset viewer.