|
|
@@ -5,6 +5,7 @@ import json
|
|
|
import re
|
|
|
import base64
|
|
|
import argparse
|
|
|
+import subprocess
|
|
|
|
|
|
b64id = base64.b64encode(os.urandom(9))
|
|
|
|
|
|
@@ -22,11 +23,25 @@ infile = arg.src
|
|
|
outfile = arg.dst
|
|
|
|
|
|
with open(infile[0], 'rb') as fpin:
|
|
|
- data = json.loads(fpin.read())
|
|
|
- data['device_id'] = theid
|
|
|
- data['installDir'] = arg.programspath
|
|
|
- data['receivers_count'] = arg.receivers
|
|
|
- data['apiSecret'] = arg.api_secret
|
|
|
- with open(outfile[0], 'w') as fpout:
|
|
|
- fpout.write(json.dumps(data, indent=4))
|
|
|
- print(theid)
|
|
|
+ data = json.loads(fpin.read())
|
|
|
+ data['device_id'] = theid
|
|
|
+ data['installDir'] = arg.programspath
|
|
|
+ data['receivers_count'] = arg.receivers
|
|
|
+ data['apiSecret'] = arg.api_secret
|
|
|
+ with open(outfile[0], 'w') as fpout:
|
|
|
+ fpout.write(json.dumps(data, indent=4))
|
|
|
+ print(theid)
|
|
|
+
|
|
|
+fourier_path = '/var/fourier'
|
|
|
+box_path = os.path.join(fourier_path, theid)
|
|
|
+db_path = os.path.join(box_path, 'files.db')
|
|
|
+if os.path.isdir(fourier_path):
|
|
|
+ if not os.path.isdir(box_path):
|
|
|
+ print('** Creating Box ID folder')
|
|
|
+ os.mkdir(box_path)
|
|
|
+ if not os.path.isfile(db_path):
|
|
|
+ print('** Preparing local database')
|
|
|
+ subprocess.call(['fourier', 'db', 'setup'])
|
|
|
+ print('** Applying migrations')
|
|
|
+ subprocess.call(['fourier', 'db', 'migrate'])
|
|
|
+ print('** Creating database')
|