docs: def InitializeNoPrompt(config=None,
                         external_hostname = None,
                         admin_password = None,
                         mysql_hostname = None,
                         mysql_port = None,
                         mysql_username = None,
                         mysql_password = None,
                         mysql_db = None,
                         mysql_client_key_path = None,
                         mysql_client_cert_path = None,
                         mysql_ca_cert_path = None,
                         redownload_templates = False,
                         repack_templates = True,
                         token = None):
    """Initialize GRR with no prompts.
  
    Args:
      config: config object
      external_hostname: A hostname.
      admin_password: A password used for the admin user.
      mysql_hostname: A hostname used for establishing connection to MySQL.
      mysql_port: A port used for establishing connection to MySQL.
      mysql_username: A username used for establishing connection to MySQL.
      mysql_password: A password used for establishing connection to MySQL.
      mysql_db: Name of the MySQL database to use.
      mysql_client_key_path: The path name of the client private key file.
      mysql_client_cert_path: The path name of the client public key certificate.
      mysql_ca_cert_path: The path name of the CA certificate file.
      redownload_templates: Indicates whether templates should be re-downloaded.
      repack_templates: Indicates whether templates should be re-packed.
      token: auth token
  
    Raises:
      ValueError: if required flags are not provided, or if the config has
        already been initialized.
      IOError: if config is not writeable
      ConfigInitError: if GRR is unable to connect to a running MySQL instance.
  
    This method does the minimum work necessary to configure GRR without any user
    prompting, relying heavily on config default values. User must supply the
    external hostname, admin password, and MySQL password; everything else is set
    automatically.
    """
    if config["Server.initialized"]:
      raise ValueError("Config has already been initialized.")
    if not external_hostname:
      raise ValueError(
          "--noprompt set, but --external_hostname was not provided.")
    if not admin_password:
      raise ValueError("--noprompt set, but --admin_password was not provided.")
    if mysql_password is None:
      raise ValueError("--noprompt set, but --mysql_password was not provided.")
  
    print("Checking write access on config %s" % config.parser)
    if not os.access(config.parser.filename, os.W_OK):
      raise IOError("Config not writeable (need sudo?)")
  
    config_dict = {}
    config_dict["Datastore.implementation"] = "MySQLAdvancedDataStore"
    config_dict["Mysql.host"] = mysql_hostname or config["Mysql.host"]
    config_dict["Mysql.port"] = mysql_port or config["Mysql.port"]
    config_dict["Mysql.database_name"] = mysql_db or config["Mysql.database_name"]
    config_dict["Mysql.database_username"] = (
        mysql_username or config["Mysql.database_username"])
    config_dict["Client.server_urls"] = [
        "http://%s:%s/" % (external_hostname, config["Frontend.bind_port"])
    ]
    config_dict["AdminUI.url"] = "http://%s:%s" % (external_hostname,
                                                   config["AdminUI.port"])
    config_dict["Logging.domain"] = external_hostname
    config_dict["Monitoring.alert_email"] = ("grr-monitoring@%s" %
                                             external_hostname)
    config_dict["Monitoring.emergency_access_email"] = ("grr-emergency@%s" %
                                                        external_hostname)
    # Print all configuration options, except for the MySQL password.
    print("Setting configuration as:\n\n%s" % config_dict)
    config_dict["Mysql.database_password"] = mysql_password
  
    if mysql_client_key_path is not None:
      config_dict["Mysql.client_key_path"] = mysql_client_key_path
      config_dict["Mysql.client_cert_path"] = mysql_client_cert_path
      config_dict["Mysql.ca_cert_path"] = mysql_ca_cert_path
  
    if CheckMySQLConnection(config_dict):
      print("Successfully connected to MySQL with the given configuration.")
    else:
      print("Error: Could not connect to MySQL with the given configuration.")
      raise ConfigInitError()
    for key, value in iteritems(config_dict):
      config.Set(key, value)
    config_updater_keys_util.GenerateKeys(config)
    FinalizeConfigInit(
        config,
        token,
        admin_password=admin_password,
        redownload_templates=redownload_templates,
        repack_templates=repack_templates,
        prompt=False)