OLD | NEW |
1 #!/usr/bin/python | 1 #!/usr/bin/python |
2 # Copyright (c) 2006-2009 The Chromium Authors. All rights reserved. | 2 # Copyright (c) 2006-2009 The Chromium Authors. All rights reserved. |
3 # Use of this source code is governed by a BSD-style license that can be | 3 # Use of this source code is governed by a BSD-style license that can be |
4 # found in the LICENSE file. | 4 # found in the LICENSE file. |
5 | 5 |
6 """Platform-specific utility methods shared by several scripts.""" | 6 """Platform-specific utility methods shared by several scripts.""" |
7 | 7 |
8 import os | 8 import os |
9 import subprocess | 9 import subprocess |
10 | 10 |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
74 apache2: boolean if true will cause this function to return start | 74 apache2: boolean if true will cause this function to return start |
75 command for Apache 2.x as opposed to Apache 1.3.x. This flag | 75 command for Apache 2.x as opposed to Apache 1.3.x. This flag |
76 is ignored on Mac (but preserved here for compatibility in | 76 is ignored on Mac (but preserved here for compatibility in |
77 function signature with win), where httpd2 is used always | 77 function signature with win), where httpd2 is used always |
78 """ | 78 """ |
79 | 79 |
80 exe_name = "httpd" | 80 exe_name = "httpd" |
81 cert_file = google.path_utils.FindUpward(self._base_dir, 'tools', | 81 cert_file = google.path_utils.FindUpward(self._base_dir, 'tools', |
82 'python', 'google', | 82 'python', 'google', |
83 'httpd_config', 'httpd2.pem') | 83 'httpd_config', 'httpd2.pem') |
| 84 ssl_enabled = os.path.exists('/etc/apache2/mods-enabled/ssl.conf') |
| 85 |
84 httpd_vars = { | 86 httpd_vars = { |
85 "httpd_executable_path": | 87 "httpd_executable_path": |
86 os.path.join(self._UnixRoot(), "usr", "sbin", exe_name), | 88 os.path.join(self._UnixRoot(), "usr", "sbin", exe_name), |
87 "httpd_conf_path": httpd_conf_path, | 89 "httpd_conf_path": httpd_conf_path, |
88 "ssl_certificate_file": cert_file, | 90 "ssl_certificate_file": cert_file, |
89 "document_root" : document_root, | 91 "document_root" : document_root, |
90 "server_root": os.path.join(self._UnixRoot(), "usr"), | 92 "server_root": os.path.join(self._UnixRoot(), "usr"), |
91 "mime_types_path": mime_types_path, | 93 "mime_types_path": mime_types_path, |
92 "output_dir": output_dir, | 94 "output_dir": output_dir, |
93 "ssl_mutex": "file:"+os.path.join(output_dir, "ssl_mutex"), | 95 "ssl_mutex": "file:"+os.path.join(output_dir, "ssl_mutex"), |
(...skipping 11 matching lines...) Expand all Loading... |
105 httpd_cmd_string = ( | 107 httpd_cmd_string = ( |
106 '%(httpd_executable_path)s' | 108 '%(httpd_executable_path)s' |
107 ' -f %(httpd_conf_path)s' | 109 ' -f %(httpd_conf_path)s' |
108 ' -c \'TypesConfig "%(mime_types_path)s"\'' | 110 ' -c \'TypesConfig "%(mime_types_path)s"\'' |
109 ' -c \'CustomLog "%(output_dir)s/access_log.txt" common\'' | 111 ' -c \'CustomLog "%(output_dir)s/access_log.txt" common\'' |
110 ' -c \'ErrorLog "%(output_dir)s/error_log.txt"\'' | 112 ' -c \'ErrorLog "%(output_dir)s/error_log.txt"\'' |
111 ' -c \'PidFile "%(output_dir)s/httpd.pid"\'' | 113 ' -c \'PidFile "%(output_dir)s/httpd.pid"\'' |
112 ' -C \'User "%(user)s"\'' | 114 ' -C \'User "%(user)s"\'' |
113 ' -C \'ServerRoot "%(server_root)s"\'' | 115 ' -C \'ServerRoot "%(server_root)s"\'' |
114 ' -c \'LockFile "%(lock_file)s"\'' | 116 ' -c \'LockFile "%(lock_file)s"\'' |
115 ' -c \'SSLCertificateFile "%(ssl_certificate_file)s"\'' | |
116 ' -c \'SSLMutex "%(ssl_mutex)s"\'' | |
117 ) | 117 ) |
118 | 118 |
119 if document_root: | 119 if document_root: |
120 httpd_cmd_string += ' -C \'DocumentRoot "%(document_root)s"\'' | 120 httpd_cmd_string += ' -C \'DocumentRoot "%(document_root)s"\'' |
| 121 |
| 122 if ssl_enabled: |
| 123 httpd_cmd_string += ( |
| 124 ' -c \'SSLCertificateFile "%(ssl_certificate_file)s"\'' |
| 125 ' -c \'SSLMutex "%(ssl_mutex)s"\'' |
| 126 ) |
| 127 |
121 # Save a copy of httpd_cmd_string to use for stopping httpd | 128 # Save a copy of httpd_cmd_string to use for stopping httpd |
122 self._httpd_cmd_string = httpd_cmd_string % httpd_vars | 129 self._httpd_cmd_string = httpd_cmd_string % httpd_vars |
123 | 130 |
124 httpd_cmd = [self._bash, "-c", self._httpd_cmd_string] | 131 httpd_cmd = [self._bash, "-c", self._httpd_cmd_string] |
125 return httpd_cmd | 132 return httpd_cmd |
126 | 133 |
127 def GetStopHttpdCommand(self): | 134 def GetStopHttpdCommand(self): |
128 """Returns a list of strings that contains the command line+args needed to | 135 """Returns a list of strings that contains the command line+args needed to |
129 stop the http server used in the http tests. | 136 stop the http server used in the http tests. |
130 | 137 |
131 This tries to fetch the pid of httpd (if available) and returns the | 138 This tries to fetch the pid of httpd (if available) and returns the |
132 command to kill it. If pid is not available, kill all httpd processes | 139 command to kill it. If pid is not available, kill all httpd processes |
133 """ | 140 """ |
134 | 141 |
135 if not self._httpd_cmd_string: | 142 if not self._httpd_cmd_string: |
136 return ["true"] # Haven't been asked for the start cmd yet. Just pass. | 143 return ["true"] # Haven't been asked for the start cmd yet. Just pass. |
137 return [self._bash, "-c", self._httpd_cmd_string + ' -k stop'] | 144 return [self._bash, "-c", self._httpd_cmd_string + ' -k stop'] |
OLD | NEW |