Skip to content

Instantly share code, notes, and snippets.

@gigablah
Created March 20, 2015 06:04
Show Gist options
  • Select an option

  • Save gigablah/da35ca7100e89e48107b to your computer and use it in GitHub Desktop.

Select an option

Save gigablah/da35ca7100e89e48107b to your computer and use it in GitHub Desktop.
#!/bin/bash
#+----------------------------------------------------------------------------------------+
#| This file is used to clean up traces from DigitalOcean *images* before being published.|
#+----------------------------------------------------------------------------------------+
unset HISTFILE
files=(/root/.mysql_history /var/log/lastlog /root/.bash_history /var/log/wtmp /var/log/auth.log /var/log/messages /root/.viminfo)
for file in ${files[*]}
do
if [[ -f "$file" ]]
then
printf "\t%s\n" $file
cat /dev/null > $file
fi
done
rm -r /root/.cache
rm -f /var/log/messages.*
rm -f /var/log/*.gz
if [ -f /etc/debian_version ]
then
DEBIAN_FRONTEND=noninteractive
apt-get autoremove -y
apt-get clean -y
fi
printf "\tPowering off.\n"
history -w
history -r
history -c
history -w && poweroff || poweroff
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment