2022-03-17 10:14:08 +01:00
|
|
|
#!/bin/bash
|
2022-02-17 13:45:43 +01:00
|
|
|
|
2022-03-23 08:33:44 +01:00
|
|
|
PATH="/usr/local/sbin:/usr/sbin:/sbin:/usr/local/bin:/usr/bin:/bin:/scripts"
|
2022-03-23 08:16:01 +01:00
|
|
|
|
2022-03-01 13:55:05 +01:00
|
|
|
# abort if not executed as root
|
2022-03-23 08:16:01 +01:00
|
|
|
if [[ $(id -u) != "0" ]]; then
|
2022-02-25 16:33:46 +01:00
|
|
|
echo "Usage: run ${0##*/} as root" 1>&2
|
2022-02-17 13:45:43 +01:00
|
|
|
exit 1
|
|
|
|
fi
|
2022-02-16 18:13:18 +01:00
|
|
|
|
|
|
|
set -o errexit
|
|
|
|
|
|
|
|
if [[ ! -d /tmp ]]; then
|
2022-03-23 08:16:01 +01:00
|
|
|
mkdir /tmp
|
2022-02-16 18:13:18 +01:00
|
|
|
fi
|
2022-02-17 13:45:43 +01:00
|
|
|
|
2022-03-23 08:16:01 +01:00
|
|
|
chmod 1777 /tmp
|
2022-02-16 18:13:18 +01:00
|
|
|
|
2022-03-23 08:16:01 +01:00
|
|
|
apt-get -y autoremove
|
|
|
|
apt-get -y autoclean
|
|
|
|
rm -rf /var/lib/apt/lists/*
|
|
|
|
rm -rf /tmp/* /var/tmp/*
|
2022-02-16 18:13:18 +01:00
|
|
|
history -c
|
2022-03-23 08:16:01 +01:00
|
|
|
cat /dev/null > /root/.bash_history
|
2022-02-16 18:13:18 +01:00
|
|
|
unset HISTFILE
|
2022-03-23 08:16:01 +01:00
|
|
|
find /var/log -mtime -1 -type f -exec truncate -s 0 {} \;
|
|
|
|
rm -rf /var/log/*.gz /var/log/*.log /var/log/*.[0-9] /var/log/*-????????
|
|
|
|
rm -rf /var/lib/cloud/instances/*
|
|
|
|
rm -f /root/.ssh/* /etc/ssh/*key*
|
2022-02-19 15:32:52 +01:00
|
|
|
|
|
|
|
echo "Done."
|