2.3 compatibility

This commit is contained in:
Jeremias Pretto
2021-03-23 15:44:44 -03:00
parent 5fba132f9c
commit b1c3677f90
3 changed files with 18 additions and 10 deletions

View File

@@ -1,14 +1,18 @@
import json
from jsonmerge import merge
import argparse
from collections import OrderedDict
file1="/opt/dev/mybots/BOTS"
file2="/opt/intelmq/intelmq/bots/BOTS"
parser = argparse.ArgumentParser(description='Merge two json.')
parser.add_argument('input_file_1', type=str, help='input_file_1')
parser.add_argument('input_file_2', type=str, help='input_file_2')
parser.add_argument('output_file', type=str, help='output_file')
args = parser.parse_args()
with open(file1, 'r') as f:
with open(args.input_file_1, 'r') as f:
j1 = json.load(f)
with open(file2, 'r') as f:
with open(args.input_file_2, 'r') as f:
j2 = json.load(f)
def sortOD(od):
@@ -26,8 +30,9 @@ merged = sortOD(merge(j1,j2))
desired_order_list = ['Collector', 'Parser', 'Expert', 'Output']
reordered_dict = {k: merged[k] for k in desired_order_list}
# add other keys
reordered_dict.update({k: merged[k] for k in merged.keys() - desired_order_list})
with open(file2, 'w') as f:
with open(args.output_file, 'w') as f:
json.dump(reordered_dict, f, indent=4)

View File

@@ -3,15 +3,18 @@
echo "Installing requirements for bots in dev repository"
for file in $(find /opt/dev/mybots -name "*REQUIREMENTS.txt"); do pip3 install -r $file; done
# Backup Original BOTS
cp /opt/intelmq/intelmq/bots/BOTS /opt/intelmq/intelmq/bots/BOTS.bk
echo "Merge your BOTS file with BOTS"
python3 /opt/dev/merge_BOTS.py
python3 /opt/dev/merge_BOTS.py "/opt/dev/mybots/BOTS" "/opt/intelmq/intelmq/bots/BOTS" "/opt/intelmq/intelmq/bots/BOTS"
cp /opt/intelmq/intelmq/bots/BOTS /opt/intelmq/etc/BOTS
echo "Copying BOTS"
cp -a /opt/dev/mybots/bots/* /opt/intelmq/intelmq/bots/
cp /opt/intelmq/intelmq/bots/BOTS /opt/intelmq/etc/BOTS
echo "Installing new BOTS"
cd /opt/intelmq && pip3 install -e . --user && python3 setup.py install --user
# Restore original BOTS
mv /opt/intelmq/intelmq/bots/BOTS.bk /opt/intelmq/intelmq/bots/BOTS