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..eaddaac --- /dev/null +++ b/uninstall @@ -0,0 +1,33 @@ +#!/usr/bin/env bash + +set -euo pipefail + +function run() { + INSTALL_PATH=/var/lib + AV_PATH=$INSTALL_PATH/aviary/av + + if [[ ! -e $INSTALL_PATH/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