Skip to content

Instantly share code, notes, and snippets.

@poundbangbash
Created February 11, 2019 16:26
Show Gist options
  • Save poundbangbash/3aec9552714011fd442d83724e12f37a to your computer and use it in GitHub Desktop.
Save poundbangbash/3aec9552714011fd442d83724e12f37a to your computer and use it in GitHub Desktop.
Munki fact to check FileVault Status
'''Check if FileVault is Active'''
import subprocess
def fact():
'''Check if FileVault is Active'''
cmd = ['/usr/bin/fdesetup', 'isactive']
run = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
output, err = run.communicate()
try:
proc = subprocess.Popen(cmd, bufsize=-1, stdout=subprocess.PIPE,
stderr=subprocess.PIPE)
(out, err) = proc.communicate()
# check if output is valid.
if "true" in out:
# Default to Des Moines location
return {'isFileVaultActive': 'True'}
else:
# Return location - strip trailing newline character
return {'isFileVaultActive': 'False'}
except OSError:
return {'isFileVaultActive': 'Unknown'}
if __name__ == '__main__':
print fact()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment