From a2da9614a64d7e0d716344e56b8d03eba3f05130 Mon Sep 17 00:00:00 2001 From: Itay Mizeretz Date: Tue, 2 Jan 2018 15:27:32 +0200 Subject: [PATCH 1/4] Make deb use virtualenv --- monkey_island/deb-package/DEBIAN/postinst | 10 ++++++---- .../deb-package/monkey_island_pip_requirements.txt | 3 ++- monkey_island/linux/ubuntu/systemd/start_server.sh | 2 +- 3 files changed, 9 insertions(+), 6 deletions(-) diff --git a/monkey_island/deb-package/DEBIAN/postinst b/monkey_island/deb-package/DEBIAN/postinst index 42b8f1eb0..502c90c5e 100644 --- a/monkey_island/deb-package/DEBIAN/postinst +++ b/monkey_island/deb-package/DEBIAN/postinst @@ -2,16 +2,18 @@ MONKEY_FOLDER=/var/monkey_island INSTALLATION_FOLDER=/var/monkey_island/installation +PYTHON_FOLDER=/var/monkey_island/bin/python cp -f ${MONKEY_FOLDER}/monkey.sh /usr/bin/monkey chmod 755 /usr/bin/monkey -# Fix dependency bug -pip uninstall -y bson +# Prepare python virtualenv +pip install virtualenv --no-index --find-links file://$INSTALLATION_FOLDER +mkdir ${MONKEY_FOLDER}/bin +virtualenv ${PYTHON_FOLDER} # install pip requirements -pip install -r $MONKEY_FOLDER/pip_requirements.txt --no-index --find-links file://$INSTALLATION_FOLDER - +${PYTHON_FOLDER}/bin/python/python -m pip install -r $MONKEY_FOLDER/pip_requirements.txt --no-index --find-links file://$INSTALLATION_FOLDER # remove installation folder and unnecessary files rm -rf ${INSTALLATION_FOLDER} diff --git a/monkey_island/deb-package/monkey_island_pip_requirements.txt b/monkey_island/deb-package/monkey_island_pip_requirements.txt index 275c8b96a..26f0f9ee2 100644 --- a/monkey_island/deb-package/monkey_island_pip_requirements.txt +++ b/monkey_island/deb-package/monkey_island_pip_requirements.txt @@ -9,4 +9,5 @@ flask Flask-Pymongo Flask-Restful jsonschema -netifaces \ No newline at end of file +netifaces +virtualenv \ No newline at end of file diff --git a/monkey_island/linux/ubuntu/systemd/start_server.sh b/monkey_island/linux/ubuntu/systemd/start_server.sh index 817da7a55..e2ea895be 100644 --- a/monkey_island/linux/ubuntu/systemd/start_server.sh +++ b/monkey_island/linux/ubuntu/systemd/start_server.sh @@ -1,4 +1,4 @@ #!/bin/bash cd /var/monkey_island/cc -python main.py \ No newline at end of file +/var/monkey_island/bin/python/python main.py \ No newline at end of file From bee1bc6f8f0701fabfbc697dcceb12b527893148 Mon Sep 17 00:00:00 2001 From: Itay Mizeretz Date: Tue, 2 Jan 2018 15:58:47 +0200 Subject: [PATCH 2/4] Fix python path --- monkey_island/deb-package/DEBIAN/postinst | 2 +- monkey_island/linux/ubuntu/systemd/start_server.sh | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/monkey_island/deb-package/DEBIAN/postinst b/monkey_island/deb-package/DEBIAN/postinst index 502c90c5e..44caa26de 100644 --- a/monkey_island/deb-package/DEBIAN/postinst +++ b/monkey_island/deb-package/DEBIAN/postinst @@ -13,7 +13,7 @@ mkdir ${MONKEY_FOLDER}/bin virtualenv ${PYTHON_FOLDER} # install pip requirements -${PYTHON_FOLDER}/bin/python/python -m pip install -r $MONKEY_FOLDER/pip_requirements.txt --no-index --find-links file://$INSTALLATION_FOLDER +${PYTHON_FOLDER}/bin/python -m pip install -r $MONKEY_FOLDER/pip_requirements.txt --no-index --find-links file://$INSTALLATION_FOLDER # remove installation folder and unnecessary files rm -rf ${INSTALLATION_FOLDER} diff --git a/monkey_island/linux/ubuntu/systemd/start_server.sh b/monkey_island/linux/ubuntu/systemd/start_server.sh index e2ea895be..ceeab57f4 100644 --- a/monkey_island/linux/ubuntu/systemd/start_server.sh +++ b/monkey_island/linux/ubuntu/systemd/start_server.sh @@ -1,4 +1,4 @@ #!/bin/bash cd /var/monkey_island/cc -/var/monkey_island/bin/python/python main.py \ No newline at end of file +/var/monkey_island/bin/python/bin/python main.py \ No newline at end of file From 3e6a2136d93f7868cb9880e66652377776e728f9 Mon Sep 17 00:00:00 2001 From: Itay Mizeretz Date: Tue, 2 Jan 2018 16:13:20 +0200 Subject: [PATCH 3/4] Don't create already created dir Remove monkey_island dir on removal --- monkey_island/deb-package/DEBIAN/postinst | 1 - monkey_island/deb-package/DEBIAN/prerm | 2 ++ 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/monkey_island/deb-package/DEBIAN/postinst b/monkey_island/deb-package/DEBIAN/postinst index 44caa26de..601fbc046 100644 --- a/monkey_island/deb-package/DEBIAN/postinst +++ b/monkey_island/deb-package/DEBIAN/postinst @@ -9,7 +9,6 @@ chmod 755 /usr/bin/monkey # Prepare python virtualenv pip install virtualenv --no-index --find-links file://$INSTALLATION_FOLDER -mkdir ${MONKEY_FOLDER}/bin virtualenv ${PYTHON_FOLDER} # install pip requirements diff --git a/monkey_island/deb-package/DEBIAN/prerm b/monkey_island/deb-package/DEBIAN/prerm index e7924c738..98557e487 100644 --- a/monkey_island/deb-package/DEBIAN/prerm +++ b/monkey_island/deb-package/DEBIAN/prerm @@ -8,4 +8,6 @@ rm -f /etc/init/monkey-mongo.conf [ -f "/lib/systemd/system/monkey-island.service" ] && rm -f /lib/systemd/system/monkey-island.service [ -f "/lib/systemd/system/monkey-mongo.service" ] && rm -f /lib/systemd/system/monkey-mongo.service +rm -r -f /var/monkey_island + exit 0 \ No newline at end of file From fd64c9dbf6c76a85309f0e6727b4766cdea3a76d Mon Sep 17 00:00:00 2001 From: Itay Mizeretz Date: Tue, 2 Jan 2018 17:53:28 +0200 Subject: [PATCH 4/4] Make sure we're using python2 --- monkey_island/deb-package/DEBIAN/postinst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/monkey_island/deb-package/DEBIAN/postinst b/monkey_island/deb-package/DEBIAN/postinst index 601fbc046..3fa922a01 100644 --- a/monkey_island/deb-package/DEBIAN/postinst +++ b/monkey_island/deb-package/DEBIAN/postinst @@ -8,8 +8,8 @@ cp -f ${MONKEY_FOLDER}/monkey.sh /usr/bin/monkey chmod 755 /usr/bin/monkey # Prepare python virtualenv -pip install virtualenv --no-index --find-links file://$INSTALLATION_FOLDER -virtualenv ${PYTHON_FOLDER} +pip2 install virtualenv --no-index --find-links file://$INSTALLATION_FOLDER +virtualenv -p python2.7 ${PYTHON_FOLDER} # install pip requirements ${PYTHON_FOLDER}/bin/python -m pip install -r $MONKEY_FOLDER/pip_requirements.txt --no-index --find-links file://$INSTALLATION_FOLDER