mirror of
https://github.com/certat/intelmq-docker.git
synced 2025-12-06 17:22:57 +01:00
2.3 compatibility
This commit is contained in:
@@ -1,14 +1,18 @@
|
|||||||
import json
|
import json
|
||||||
from jsonmerge import merge
|
from jsonmerge import merge
|
||||||
|
import argparse
|
||||||
from collections import OrderedDict
|
from collections import OrderedDict
|
||||||
|
|
||||||
file1="/opt/dev/mybots/BOTS"
|
parser = argparse.ArgumentParser(description='Merge two json.')
|
||||||
file2="/opt/intelmq/intelmq/bots/BOTS"
|
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)
|
j1 = json.load(f)
|
||||||
with open(file2, 'r') as f:
|
with open(args.input_file_2, 'r') as f:
|
||||||
j2 = json.load(f)
|
j2 = json.load(f)
|
||||||
|
|
||||||
def sortOD(od):
|
def sortOD(od):
|
||||||
@@ -26,8 +30,9 @@ merged = sortOD(merge(j1,j2))
|
|||||||
desired_order_list = ['Collector', 'Parser', 'Expert', 'Output']
|
desired_order_list = ['Collector', 'Parser', 'Expert', 'Output']
|
||||||
reordered_dict = {k: merged[k] for k in desired_order_list}
|
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})
|
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)
|
json.dump(reordered_dict, f, indent=4)
|
||||||
|
|
||||||
|
|||||||
@@ -3,15 +3,18 @@
|
|||||||
echo "Installing requirements for bots in dev repository"
|
echo "Installing requirements for bots in dev repository"
|
||||||
for file in $(find /opt/dev/mybots -name "*REQUIREMENTS.txt"); do pip3 install -r $file; done
|
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"
|
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"
|
echo "Copying BOTS"
|
||||||
cp -a /opt/dev/mybots/bots/* /opt/intelmq/intelmq/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"
|
echo "Installing new BOTS"
|
||||||
cd /opt/intelmq && pip3 install -e . --user && python3 setup.py install --user
|
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
|
||||||
|
|||||||
@@ -40,6 +40,6 @@ Just clone your bots git to ./mybots and run the container
|
|||||||
|
|
||||||
For example, using https://github.com/CERTUNLP/intelmq-bots:
|
For example, using https://github.com/CERTUNLP/intelmq-bots:
|
||||||
|
|
||||||
1. `git clone https://github.com/CERTUNLP/intelmq-bots mybots`
|
1. `git clone https://github.com/CERTUNLP/intelmq-bots mybots -b 2.3`
|
||||||
0. `docker-compose -f docker-compose-dev.yml up`
|
0. `docker-compose -f docker-compose-dev.yml up`
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user