From 9ff46cb1e686824fd7866fe54307e9c6b63558e1 Mon Sep 17 00:00:00 2001 From: Einar Lanfranco Date: Thu, 25 Mar 2021 15:41:24 -0300 Subject: [PATCH] Wagner suggestions --- .docker/intelmq-full-dev/Dockerfile | 7 ++----- .docker/intelmq-full-dev/merge_BOTS.py | 2 +- .docker/intelmq-full-dev/update.sh | 28 ++++++++++++++++---------- mybots/BOTS | 2 +- 4 files changed, 21 insertions(+), 18 deletions(-) diff --git a/.docker/intelmq-full-dev/Dockerfile b/.docker/intelmq-full-dev/Dockerfile index 8b18930..f8dc9a0 100644 --- a/.docker/intelmq-full-dev/Dockerfile +++ b/.docker/intelmq-full-dev/Dockerfile @@ -3,20 +3,17 @@ FROM certat/intelmq-full:1.0 MAINTAINER Einar MAINTAINER Jeremias -USER root - ADD entrypoint_dev.sh /opt/dev/entrypoint_dev.sh ADD update.sh /opt/dev/update.sh ADD merge_BOTS.py /opt/dev/merge_BOTS.py # Merge bots for merge_BOTS.py -RUN python3 -m pip install jsonmerge +RUN sudo python3 -m pip install jsonmerge # Permission denied when installing new bots -RUN chown -R intelmq:intelmq /opt/intelmq/intelmq.egg-info +RUN sudo chown -R intelmq:intelmq /opt/intelmq/intelmq.egg-info -USER intelmq:intelmq ENV PATH="/opt/intelmq/.local/bin:${PATH}" ENTRYPOINT ["/opt/dev/entrypoint_dev.sh"] diff --git a/.docker/intelmq-full-dev/merge_BOTS.py b/.docker/intelmq-full-dev/merge_BOTS.py index f56e6de..3c28494 100644 --- a/.docker/intelmq-full-dev/merge_BOTS.py +++ b/.docker/intelmq-full-dev/merge_BOTS.py @@ -35,4 +35,4 @@ reordered_dict.update({k: merged[k] for k in merged.keys() - desired_order_list} with open(args.output_file, 'w') as f: json.dump(reordered_dict, f, indent=4) - + \ No newline at end of file diff --git a/.docker/intelmq-full-dev/update.sh b/.docker/intelmq-full-dev/update.sh index b3a0061..83b2470 100755 --- a/.docker/intelmq-full-dev/update.sh +++ b/.docker/intelmq-full-dev/update.sh @@ -3,18 +3,24 @@ 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 "/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/ +if [ test -f /opt/intelmq/intelmq/bots/BOTS ]; then + if [ "${AUTO_MIX_BOTS}" = "true" ]; then + # 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 "/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/ + # Restore original BOTS + mv /opt/intelmq/intelmq/bots/BOTS.bk /opt/intelmq/intelmq/bots/BOTS + else + cp /opt/intelmq/etc/BOTS /opt/intelmq/intelmq/bots/BOTS + fi +fi 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 + + diff --git a/mybots/BOTS b/mybots/BOTS index 185295d..feaa198 100644 --- a/mybots/BOTS +++ b/mybots/BOTS @@ -14,4 +14,4 @@ "Output": { } -} \ No newline at end of file +}