예제 #1
0
파일: jamJAR.py 프로젝트: apizz/jamJAR
def update_counts():
    ''' Update counts for policy log '''

    # Some vars for tings & junk
    jamjar_installs = []
    jamjar_uninstalls = []
    warning_count = 0

    # Get items in the LocalOnlyManifests managed_installs array
    if CLIENT_MANIFEST.get('managed_installs'):
        for items in CLIENT_MANIFEST.get('managed_installs'):
            jamjar_installs.append(items)
    if CLIENT_MANIFEST.get('managed_uninstalls'):
        for items in CLIENT_MANIFEST.get('managed_uninstalls'):
            jamjar_uninstalls.append(items)

    # Get integer values of pending items in the ManagedInstalls & uk.co.dataJAR.jamJAR plists
    pending_count = CFPreferencesGetAppIntegerValue('PendingUpdateCount',
                                                    'ManagedInstalls', None)[0]
    # Check if ManagedInstallReport exists
    install_report_plist = '%s/ManagedInstallReport.plist' % MANAGED_INSTALL_DIR
    if not os.path.exists(install_report_plist):
        print 'ManagedInstallReport is missing'
    else:
        managed_install_report = {}
        managed_install_report = FoundationPlist.readPlist(
            install_report_plist)
        for warnings in managed_install_report.get('Warnings'):
            print 'Warning: %s' % warnings
            warning_count += 1

    # Postflight policy text
    print 'Postflight: Contains %s installs %s, %s uninstalls %s, %s pending, %s warnings' % (
        len(jamjar_installs), jamjar_installs, len(jamjar_uninstalls),
        jamjar_uninstalls, pending_count, warning_count)
예제 #2
0
def screensaver_password_active():
    '''Is askForPassword set to True for the screensaver?'''
    is_on, is_good = CFPreferencesGetAppIntegerValue(
        'askForPassword', 'com.apple.screensaver', None)
    if is_on and is_good:
        return True
    return False
예제 #3
0
def main():
    ''' Check parameters & update manifest as needed, send alert if ran via Self Service &
        uptodate. Force install if wanted. '''

    # Some vars for tings & junk
    jamjar_installs = []
    jamjar_uninstalls = []
    user_name = ''
    warning_count = 0
    yolo_mode = ''

    # Get items in the LocalOnlyManifests managed_installs array
    if CLIENT_MANIFEST.get('managed_installs'):
        for items in CLIENT_MANIFEST.get('managed_installs'):
            jamjar_installs.append(items)
    if CLIENT_MANIFEST.get('managed_uninstalls'):
        for items in CLIENT_MANIFEST.get('managed_uninstalls'):
            jamjar_uninstalls.append(items)

    # Processes parameters
    user_name, jamjar_installs, jamjar_uninstalls, yolo_mode = process_parameters(
        user_name, jamjar_installs, jamjar_uninstalls, yolo_mode)

    # Remove any duplicate entries in jamjar_installs & jamjar_uninstalls
    jamjar_installs = list(set(jamjar_installs))
    jamjar_uninstalls = list(set(jamjar_uninstalls))
    warning_count = process_warnings(warning_count)

    # Get integer values of pending items in the ManagedInstalls & uk.co.dataJAR.jamJAR plists
    pending_count = CFPreferencesGetAppIntegerValue('PendingUpdateCount',
                                                    'ManagedInstalls', None)[0]
    # Update manifest
    update_client_manifest(jamjar_installs, jamjar_uninstalls)

    # Preflight policy text
    print(
        'Preflight: Contains %s installs %s, %s uninstalls %s, %s pending, %s warnings'
        % (len(jamjar_installs), jamjar_installs, len(jamjar_uninstalls),
           jamjar_uninstalls, pending_count, warning_count))

    # Run managedsoftwareupdate
    if yolo_mode == 'ENGAGE':
        print('WARNING: YOLO mode engaged')
        run_managedsoftwareupdate_yolo()
    else:
        run_managedsoftwareupdate_auto()

    # If running under Self Service, then USERNAME is None but we'll have a USER
    if not os.environ.get('USERNAME') and os.environ.get(
            'USER') and os.environ.get('USER') != 'root':
        # Give feedback that items are uptodate
        process_uptodate()

    # Update counts after installs
    update_counts()