def call_post_bootstrap(self, config: Dict[str, Any]) -> bool:
        """
        runs a script after initdb or custom bootstrap script is called and waits until completion.
        """
        cmd = config.get('post_bootstrap') or config.get('post_init')
        if cmd:
            r = self._postgresql.connection_pool.conn_kwargs

            # https://www.postgresql.org/docs/current/static/libpq-pgpass.html
            # A host name of localhost matches both TCP (host name localhost) and Unix domain socket
            # (pghost empty or the default socket directory) connections coming from the local machine.
            env = self._postgresql.config.write_pgpass({'host': 'localhost', **r})
            env['PGOPTIONS'] = '-c synchronous_commit=local -c statement_timeout=0'
            connstring = self._postgresql.config.format_dsn({**r, 'password': None})

            try:
                ret = self._postgresql.cancellable.call(shlex.split(cmd) + [connstring], env=env)
            except OSError:
                logger.error('post_init script %s failed', cmd)
                return False
            if ret != 0:
                logger.error('post_init script %s returned non-zero code %d', cmd, ret)
                return False
        return True

        runs a script after initdb or custom bootstrap script is called and waits until completion.
        
patroni/postgresql/bootstrap.py