def manager_init():
    set_time(cloudlog)
    params = Params()
    params.clear_all(ParamKeyType.CLEAR_ON_MANAGER_START)
    default_params = [('CompletedTrainingVersion', '0'), ('HasAcceptedTerms', '0'), ('LastUpdateTime', datetime.datetime.utcnow().isoformat().encode('utf8')), ('OpenpilotEnabledToggle', '1'), ('IsMetric', '1'), ('UseClusterSpeed', '1'), ('LongControlEnabled', '0'), ('MadModeEnabled', '1'), ('AutoLaneChangeEnabled', '0'), ('SccSmootherSlowOnCurves', '0'), ('SccSmootherSyncGasPressed', '0'), ('ShowDebugUI', '0')]
    if TICI:
        default_params.append(('IsUploadRawEnabled', '1'))
    if params.get_bool('RecordFrontLock'):
        params.put_bool('RecordFront', True)
    for (k, v) in default_params:
        if (params.get(k) is None):
            params.put(k, v)
    if (os.getenv('PASSIVE') is not None):
        params.put_bool('Passive', bool(int(os.getenv('PASSIVE'))))
    if (params.get('Passive') is None):
        raise Exception('Passive must be set to continue')
    os.umask(0)
    try:
        os.mkdir('/dev/shm')
    except FileExistsError:
        pass
    except PermissionError:
        print('WARNING: failed to make /dev/shm')
    params.put('Version', version)
    params.put('TermsVersion', terms_version)
    params.put('TrainingVersion', training_version)
    params.put('GitCommit', get_git_commit(default=''))
    params.put('GitBranch', get_git_branch(default=''))
    params.put('GitRemote', get_git_remote(default=''))
    reg_res = register(show_spinner=True)
    if reg_res:
        dongle_id = reg_res
    else:
        serial = params.get('HardwareSerial')
        raise Exception(f'Registration failed for device {serial}')
    os.environ['DONGLE_ID'] = dongle_id
    if (not dirty):
        os.environ['CLEAN'] = '1'
    cloudlog.bind_global(dongle_id=dongle_id, version=version, dirty=dirty, device=HARDWARE.get_device_type())
    if (comma_remote and (not (os.getenv('NOLOG') or os.getenv('NOCRASH') or PC))):
        crash.init()
    crash.bind_user(id=dongle_id)
    crash.bind_extra(dirty=dirty, origin=origin, branch=branch, commit=commit, device=HARDWARE.get_device_type())
def manager_init():
    set_time(cloudlog)
    params = Params()
    params.clear_all(ParamKeyType.CLEAR_ON_MANAGER_START)
    default_params = [('CompletedTrainingVersion', '0'), ('HasAcceptedTerms', '0'), ('LastUpdateTime', datetime.datetime.utcnow().isoformat().encode('utf8')), ('OpenpilotEnabledToggle', '1'), ('IsMetric', '1'), ('UseClusterSpeed', '1'), ('LongControlEnabled', '0'), ('MadModeEnabled', '1'), ('AutoLaneChangeEnabled', '0'), ('SccSmootherSlowOnCurves', '0'), ('SccSmootherSyncGasPressed', '0'), ('ShowDebugUI', '0')]
    if TICI:
        default_params.append(('IsUploadRawEnabled', '1'))
    if params.get_bool('RecordFrontLock'):
        params.put_bool('RecordFront', True)
    for (k, v) in default_params:
        if (params.get(k) is None):
            params.put(k, v)
    if (os.getenv('PASSIVE') is not None):
        params.put_bool('Passive', bool(int(os.getenv('PASSIVE'))))
    if (params.get('Passive') is None):
        raise Exception('Passive must be set to continue')
    os.umask(0)
    try:
        os.mkdir('/dev/shm')
    except FileExistsError:
        pass
    except PermissionError:
        print('WARNING: failed to make /dev/shm')
    params.put('Version', version)
    params.put('TermsVersion', terms_version)
    params.put('TrainingVersion', training_version)
    params.put('GitCommit', get_git_commit(default=))
    params.put('GitBranch', get_git_branch(default=))
    params.put('GitRemote', get_git_remote(default=))
    reg_res = register(show_spinner=True)
    if reg_res:
        dongle_id = reg_res
    else:
        serial = params.get('HardwareSerial')
        raise Exception(f'Registration failed for device {serial}')
    os.environ['DONGLE_ID'] = dongle_id
    if (not dirty):
        os.environ['CLEAN'] = '1'
    cloudlog.bind_global(dongle_id=dongle_id, version=version, dirty=dirty, device=HARDWARE.get_device_type())
    if (comma_remote and (not (os.getenv('NOLOG') or os.getenv('NOCRASH') or PC))):
        crash.init()
    crash.bind_user(id=dongle_id)
    crash.bind_extra(dirty=dirty, origin=origin, branch=branch, commit=commit, device=HARDWARE.get_device_type())