-
Notifications
You must be signed in to change notification settings - Fork 2
/
rotate_opendkim_keys.py
executable file
·36 lines (27 loc) · 1.03 KB
/
rotate_opendkim_keys.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
#!/usr/bin/env python
import grp
import os
import pwd
import sys
from odkim_rotate.key_table import *
from odkim_rotate.manager import *
from odkim_rotate.utils import *
def main(verbose):
manager = Manager(verbose)
manager.opendkim_conf = '/etc/opendkim.conf'
manager.opendkim_keys_basedir = '/etc/dkimkeys'
manager.opendkim_genkey = '/usr/bin/opendkim-genkey'
manager.opendkim_testkey = '/usr/bin/opendkim-testkey'
manager.key_owner = 'opendkim'
manager.key_owner_uid = pwd.getpwnam(manager.key_owner).pw_uid
manager.key_group = 'opendkim'
manager.key_group_gid = grp.getgrnam(manager.key_group).gr_gid
manager.dns_provider = create_dns_provider('linode')
manager.keytable_path = get_keytable_path(manager.opendkim_conf)
manager.keytable = KeyTable(manager.keytable_path)
manager.rotate_keys()
if __name__ == '__main__':
if os.getenv('USER') != 'root':
print('Error: script must be run as root')
sys.exit(os.EX_USAGE)
main(len(sys.argv) == 2 and sys.argv[1] == '-v')