forked from nmcspadden/SalProfileGenerator
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgenerate_sal_profile.py
executable file
·40 lines (29 loc) · 1.2 KB
/
generate_sal_profile.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#!/usr/bin/python
import argparse
import os
from mcxToProfile import *
parser = argparse.ArgumentParser()
parser.add_argument("key", help="Machine Group key")
parser.add_argument("-u", "--url", help="Server URL to Sal. Defaults to http://sal.")
parser.add_argument("-o", "--output", help="Path to output .mobileconfig. Defaults to 'com.github.salopensource.sal' in current working directory.")
args = parser.parse_args()
plistDict = dict()
if args.url:
plistDict['ServerURL'] = args.url
else:
plistDict['ServerURL'] = "http://sal"
plistDict['key'] = args.key
newPayload = PayloadDict("com.github.salopensource.sal", makeNewUUID(), False, "Sal", "Sal")
newPayload.addPayloadFromPlistContents(plistDict, 'com.github.salopensource.sal', 'Always')
filename = "com.github.salopensource.sal"
filename+="." + plistDict['key'][0:5]
if args.output:
if os.path.isdir(args.output):
output_path = os.path.join(args.output, filename + '.mobileconfig')
elif os.path.isfile(args.output):
output_path = args.output
else:
print "Invalid path: %s. Must be a valid directory or an output file." % args.output
else:
output_path = os.path.join(os.getcwd(), filename + '.mobileconfig')
newPayload.finalizeAndSave(output_path)