Files
self-host/CommonMarketplace/scripts/90-cleanup.sh
Kyle Spearrin b61b666b0b Consolidate marketplace assets (#479)
* azure cleanup

* cleanup packer keys

* cleanup azure

* consolidate marketplace assets

* dev build versions
2026-03-30 16:02:35 -04:00

30 lines
746 B
Bash

#!/bin/bash
# Marketplace Image Cleanup
set -o errexit
# Ensure /tmp exists and has the proper permissions
if [ ! -d /tmp ]; then
mkdir /tmp
fi
chmod 1777 /tmp
if [ -n "$(command -v apt-get)" ]; then
export DEBIAN_FRONTEND=noninteractive
apt-get -y update
apt-get -o Dpkg::Options::="--force-confold" upgrade -q -y
apt-get -y autoremove
apt-get -y autoclean
fi
rm -rf /tmp/* /var/tmp/*
cat /dev/null > /root/.bash_history
unset HISTFILE
find /var/log -mtime -1 -type f -exec truncate -s 0 {} \;
rm -rf /var/log/*.gz /var/log/*.[0-9] /var/log/*-????????
rm -rf /var/lib/cloud/instances/*
rm -f /root/.ssh/authorized_keys /home/ubuntu/.ssh/authorized_keys /etc/ssh/*key*
touch /etc/ssh/revoked_keys
chmod 600 /etc/ssh/revoked_keys