Skip to content

Instantly share code, notes, and snippets.

@matglas
Created September 3, 2013 06:18
Show Gist options
  • Select an option

  • Save matglas/6420253 to your computer and use it in GitHub Desktop.

Select an option

Save matglas/6420253 to your computer and use it in GitHub Desktop.
Clean up old build in Kraftwagen.
#!/bin/bash
DIR=`pwd`
if [ -d "$DIR/builds" ]
then
CURRENT=`ls -1 builds | sort | tail -1`
read -p "Do you want to remove all the old builds except $CURRENT (y/n)" -n 1 -s REMOVE_OLD_BUILDS
echo ""
if [ $REMOVE_OLD_BUILDS == "y" ]
then
for BUILD in $(ls -1 builds | sort)
do
# Remove build
if [ "$BUILD" != "$CURRENT" ]
then
sudo rm -rf "$DIR/builds/$BUILD"
fi
done
echo "Removed old builds"
else
echo "Safe choice :)"
fi
else
echo "No builds dir found."
fi
@matglas

matglas commented Sep 5, 2013

Copy link
Copy Markdown
Author

I should check what the origina of the build folder is (check the symlink of build) to be sure not to remove the live version.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment