Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create crontab backup and uninstaller #4

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions install
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
33 changes: 33 additions & 0 deletions uninstall
Original file line number Diff line number Diff line change
@@ -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