function initManagement(log, callback) {
    if ((process.env.REMOTE_MANAGEMENT_DISABLE &&
        process.env.REMOTE_MANAGEMENT_DISABLE !== '0')
        || process.env.S3BACKEND === 'mem') {
        log.info('remote management disabled');
        return;
    }

    /* Temporary check before to fully move to the process management agent. */
    if (isManagementAgentUsed() ^ typeof callback === 'function') {
        let msg = 'misuse of initManagement function: ';
        msg += `MANAGEMENT_USE_AGENT: ${process.env.MANAGEMENT_USE_AGENT}`;
        msg += `, callback type: ${typeof callback}`;
        throw new Error(msg);
    }

    async.waterfall([
        // eslint-disable-next-line arrow-body-style
        cb => { return isManagementAgentUsed() ? metadata.setup(cb) : cb(); },
        cb => initManagementDatabase(log, cb),
        cb => metadata.getUUID(log, cb),
        (instanceId, cb) => initManagementCredentials(
            managementEndpoint, instanceId, log, cb),
        (instanceId, token, cb) => {
            if (!isManagementAgentUsed()) {
                cb(null, instanceId, token, {});
                return;
            }
            loadCachedOverlay(log, (err, overlay) => cb(err, instanceId,
                                                        token, overlay));
        },
        (instanceId, token, overlay, cb) => {
            if (!isManagementAgentUsed()) {
                cb(null, instanceId, token, overlay);
                return;
            }
            patchConfiguration(overlay, log,
                               err => cb(err, instanceId, token, overlay));
        },
    ], (error, instanceId, token, overlay) => {
        if (error) {
            log.error('could not initialize remote management, retrying later',
                { error: reshapeExceptionError(error),
                  method: 'initManagement' });
            setTimeout(initManagement,
                       initRemoteManagementRetryDelay,
                       logger.newRequestLogger());
        } else {
            log.info(`this deployment's Instance ID is ${instanceId}`);
            log.end('management init done');
            startManagementListeners(instanceId, token);
            if (callback) {
                callback(overlay);
            }
        }
    });
}
Initializes Orbit-based management by:
- creating the management database in metadata
- generating a key pair for credentials encryption
- generating an instance-unique ID
- getting an authentication token for the API
- loading and applying the latest cached overlay configuration
- starting a configuration update and metrics push background task

@param  {werelogs~Logger} log Request-scoped logger to be able to trace
 initialization process
@param  {function} callback Function to call once the overlay is loaded
 (overlay)

@returns {undefined}