diff --git a/setup/web.sh b/setup/web.sh index e5c29458..2aad8d05 100755 --- a/setup/web.sh +++ b/setup/web.sh @@ -13,6 +13,11 @@ rm -f /etc/nginx/sites-enabled/default # SSL settings from @konklone cp conf/nginx-ssl.conf /etc/nginx/nginx-ssl.conf +# Fix some nginx defaults. +# The server_names_hash_bucket_size seems to prevent long domain names? +tools/editconf.py /etc/nginx/nginx.conf -s \ + server_names_hash_bucket_size="64;" + # Other nginx settings will be configured by the management service # since it depends on what domains we're serving, which we don't know # until mail accounts have been created. diff --git a/tools/editconf.py b/tools/editconf.py index 47ca1b0a..329b0f9c 100755 --- a/tools/editconf.py +++ b/tools/editconf.py @@ -68,24 +68,29 @@ while len(input_lines) > 0: for i in range(len(settings)): # Check that this line contain this setting from the command-line arguments. name, val = settings[i].split("=", 1) - m = re.match("\s*" + re.escape(name) + delimiter_re + "(.*?)\s*$", line, re.S) + m = re.match("(\s*)(#\s*)?" + re.escape(name) + delimiter_re + "(.*?)\s*$", line, re.S) if not m: continue + indent, is_comment, existing_val = m.groups() # If this is already the setting, do nothing. - if m.group(1) == val: + if is_comment is None and existing_val == val: buf += line found.add(i) break # comment-out the existing line (also comment any folded lines) - buf += "#" + line.rstrip().replace("\n", "\n#") + "\n" + if is_comment is None: + buf += "#" + line.rstrip().replace("\n", "\n#") + "\n" + else: + # the line is already commented, pass it through + buf += line # if this option oddly appears more than once, don't add the setting again if i in found: break # add the new setting - buf += name + delimiter + val + "\n" + buf += indent + name + delimiter + val + "\n" # note that we've applied this option found.add(i)