-
Notifications
You must be signed in to change notification settings - Fork 6
/
prefSetter.py
executable file
·52 lines (43 loc) · 1.82 KB
/
prefSetter.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
41
42
43
44
45
46
47
48
49
50
51
52
#!/usr/bin/python
"""
Helper script to set preferences for s3Repo plugin.
Sorry I wanted nested dictonaries. Deal with it. This allows you to have
multiple 'profiles' for usage. Change the `profile_name` value and run this
script to create or update a profile. To switch to that profile use:
export S3REPO_PROFILE='NEW_VALUE_HERE' (sh/bash/zsh)
set -x S3REPO_PROFILE 'NEW_VALUE_HERE' (fish)
I am making the assumption that you wish to store your preferences under
~/Library/Preferences/com.clburlison.munki.s3Repo.
You will _need_ to make modifications to the `prefs` dictonary.
"""
from Foundation import CFPreferencesSetMultiple, \
kCFPreferencesAnyHost, \
kCFPreferencesCurrentUser
bundle_id = 'com.clburlison.munki.s3Repo'
profile_name = 'default'
prefs = {
profile_name: {
'aws_access_key_id': '1234',
'aws_secret_access_key': 'asdf',
'bucket': 'clburlison-munkirepo',
'region': 'us-east-1',
'ExtraArgs': {
'ACL': 'public-read',
'StorageClass': 'REDUCED_REDUNDANCY',
'Metadata': {
'Cache-Control': '86400',
},
},
'default_class': 'REDUCED_REDUNDANCY',
'default_age': 86400,
'catalogs_age': 120,
'manifests_age': 120,
}
}
CFPreferencesSetMultiple(
prefs, # 1. our dictionary of keys/values to set
[], # 2. a list of keys to _remove_
bundle_id, # 3. the domain
kCFPreferencesCurrentUser, # 4. current- or any-user (ie. ~/L/P or /L/P)
kCFPreferencesAnyHost # 5. current- or any-host (ie. ByHost or not)
)