From 686e968e1c87fb72dd5278442c518c2c3daa5233 Mon Sep 17 00:00:00 2001 From: Luke Tainton Date: Sat, 27 Jun 2020 15:46:04 +0100 Subject: [PATCH 1/2] =?UTF-8?q?=F0=9F=91=8C=20IMPROVE:=20Create=20crontab?= =?UTF-8?q?=20backup=20and=20uninstaller?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Luke Tainton --- install | 3 +++ uninstall | 34 ++++++++++++++++++++++++++++++++++ 2 files changed, 37 insertions(+) create mode 100644 uninstall diff --git a/install b/install index 02f0f0b..f52e94b 100644 --- a/install +++ b/install @@ -35,6 +35,9 @@ function run() { echo "inventory_git_url=$INVENTORY_GIT_URL" >> $CONFIG_FILE fi + echo Making a backup of /etc/crontab... + cp /etc/crontab /etc/crontab-pre-aviary + echo Adding entry to /etc/crontab... echo "$(cat /etc/crontab | grep -v $AV_PATH)" > /etc/crontab echo "* * * * * root $AV_PATH directive >> /var/log/aviary-directive.log 2>&1" >> /etc/crontab diff --git a/uninstall b/uninstall new file mode 100644 index 0000000..9fcbe07 --- /dev/null +++ b/uninstall @@ -0,0 +1,34 @@ +#!/usr/bin/env bash + +set -euo pipefail + +function run() { + VERSION=1.3.2 + INSTALL_PATH=/var/lib + AV_PATH=$INSTALL_PATH/aviary/av + + if [[ ! -e /var/lib/aviary ]]; then + echo "No existing installation at $INSTALL_PATH; exiting" + exit 1 + fi + + echo Uninstalling aviary from ${INSTALL_PATH}... + rm -rf ${INSTALL_PATH}/aviary + rm -f /usr/bin/av + + echo Removing entries from /etc/crontab... + cp /etc/crontab /etc/crontab-aviary-uninstall + grep -v "$INSTALL_PATH/aviary" /etc/crontab > /etc/crontab.new + mv /etc/crontab.new /etc/crontab + if grep -q "$INSTALL_PATH/aviary" "/etc/crontab"; then + echo ERROR: Could not remove entries - please clean up /etc/crontab manually. + else + echo /etc/crontab updated - removing backup... + rm -f /etc/crontab-aviary-uninstall + fi + + echo Done +} + +# Wrap in function to ensure entire script is downloaded. +run From d495175c885205511043030aa0f56c25bd99de22 Mon Sep 17 00:00:00 2001 From: Luke Tainton Date: Fri, 10 Jul 2020 14:53:11 +0100 Subject: [PATCH 2/2] =?UTF-8?q?=F0=9F=91=8C=20IMPROVE:=20Remove=20static?= =?UTF-8?q?=20pointer=20to=20/var/lib?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Luke Tainton --- uninstall | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/uninstall b/uninstall index 9fcbe07..eaddaac 100644 --- a/uninstall +++ b/uninstall @@ -3,11 +3,10 @@ set -euo pipefail function run() { - VERSION=1.3.2 INSTALL_PATH=/var/lib AV_PATH=$INSTALL_PATH/aviary/av - if [[ ! -e /var/lib/aviary ]]; then + if [[ ! -e $INSTALL_PATH/aviary ]]; then echo "No existing installation at $INSTALL_PATH; exiting" exit 1 fi