From 4ffc6e360cab81fb5c126ca16a2d970e9fae0fc9 Mon Sep 17 00:00:00 2001 From: Imdad Ahad Date: Mon, 13 Feb 2017 17:32:51 +0000 Subject: [PATCH 1/2] Remove notify app folder and installed python packages before we deploy the app --- appspec.yml | 4 ++++ scripts/aws_clear_instance.sh | 14 ++++++++++++++ 2 files changed, 18 insertions(+) create mode 100755 scripts/aws_clear_instance.sh diff --git a/appspec.yml b/appspec.yml index 882459f2e..0a55dcfa1 100644 --- a/appspec.yml +++ b/appspec.yml @@ -4,6 +4,10 @@ files: destination: /home/notify-app/notifications-admin source: / hooks: + BeforeInstall: + - location: scripts/aws_clear_instance.sh + runas: root + timeout: 1000 AfterInstall: - location: scripts/aws_install_dependencies.sh diff --git a/scripts/aws_clear_instance.sh b/scripts/aws_clear_instance.sh new file mode 100755 index 000000000..41fd44d98 --- /dev/null +++ b/scripts/aws_clear_instance.sh @@ -0,0 +1,14 @@ +#!/bin/bash + +echo "Removing application and dependencies" + +if [ -d "/home/notify-app/notifications-admin" ]; then + # Remove and re-create the directory + rm -rf /home/notify-app/notifications-admin + mkdir -vp /home/notify-app/notifications-admin + # Remove installed py3 packages + pip3 freeze | xargs pip3 uninstall -y +else + echo "Directory does not exist, something went wrong!" +fi + From 4110d06e1fb474272d9c880bf72d94da257ee19b Mon Sep 17 00:00:00 2001 From: Imdad Ahad Date: Tue, 14 Feb 2017 12:17:03 +0000 Subject: [PATCH 2/2] Cancel uninstalling python packages --- scripts/aws_clear_instance.sh | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/scripts/aws_clear_instance.sh b/scripts/aws_clear_instance.sh index 41fd44d98..1b159ddb3 100755 --- a/scripts/aws_clear_instance.sh +++ b/scripts/aws_clear_instance.sh @@ -5,10 +5,6 @@ echo "Removing application and dependencies" if [ -d "/home/notify-app/notifications-admin" ]; then # Remove and re-create the directory rm -rf /home/notify-app/notifications-admin - mkdir -vp /home/notify-app/notifications-admin - # Remove installed py3 packages - pip3 freeze | xargs pip3 uninstall -y -else - echo "Directory does not exist, something went wrong!" + mkdir -p /home/notify-app/notifications-admin fi