blob: 9749582f201bf12e8c418c9ea33b5499b4781daa (
plain)
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
|
#!/usr/bin/python
# -*- coding: utf-8 -*-
import json
import os
import sys
def main():
"""
"""
if (len(sys.argv) != 2):
sys.exit("Invalid parameter. Usage: " + sys.argv[0] + " <mapping>\n")
cstm_error = ''
try:
cstm_error = 'Could not open config'
with open(os.path.expanduser('~/.cmount.json')) as fp:
config_dict = json.load(fp)
cstm_error = 'Invalid / nonexistent mapping: {0}'.format(sys.argv[1])
data = config_dict[sys.argv[1]]
cstm_error = 'system() error'
os.system('/sbin/cryptsetup luksOpen {device} {name}'.format(
device=data['device'],
name=sys.argv[1]))
os.system('/bin/mount /dev/mapper/{name} {target}'.format(
name=sys.argv[1],
target=data['target']))
except Exception as e:
sys.stderr.write('Error: {0}\n'.format(cstm_error))
sys.stderr.flush()
if __name__ == '__main__':
main()
|