1#!/bin/csh
2#
3#
4
5echo "Clean for AMD copyimage.  This script will destroy ssh keys and"
6echo "logs, touch /firstboot, and generally make a base AMI image that"
7echo "has not been messed with a whole lot ready for an aws ec2 create-image"
8echo "operation."
9echo ""
10echo "Use:"
11echo '    aws ec2 create-image \\'
12echo '        --name YourAMINameHere \\'
13echo '        --description "Your AMI Description Here" \\'
14echo '        --instance-id i-ThisInstanceId \\'
15echo ""
16
17if ( "$argv" != "doit" ) then
18    echo "Execute script with 'doit' to really do it"
19    exit 1
20endif
21
22echo "Starting cleanup"
23sleep 1
24rm -f ~root/.ssh/{authorized_keys,known_hosts} ~root/.history
25rm -f /home/ec2-user/.ssh/{authorized_keys,known_hosts}
26rm -f /home/ec2-user/.history
27touch /firstboot
28killall syslogd
29sleep 0.1
30find /var/log -type f -delete
31touch /var/log/{auth.log,cron,daemon,maillog,messages,security,userlog}
32touch /var/log/wtmpx
33
34echo "Cleanup complete"
35