14b403a55SMatthew Dillon#!/bin/csh 24b403a55SMatthew Dillon# 34b403a55SMatthew Dillon# 44b403a55SMatthew Dillon 54b403a55SMatthew Dillonecho "Clean for AMD copyimage. This script will destroy ssh keys and" 64b403a55SMatthew Dillonecho "logs, touch /firstboot, and generally make a base AMI image that" 74b403a55SMatthew Dillonecho "has not been messed with a whole lot ready for an aws ec2 create-image" 84b403a55SMatthew Dillonecho "operation." 94b403a55SMatthew Dillonecho "" 104b403a55SMatthew Dillonecho "Use:" 114b403a55SMatthew Dillonecho ' aws ec2 create-image \\' 124b403a55SMatthew Dillonecho ' --name YourAMINameHere \\' 134b403a55SMatthew Dillonecho ' --description "Your AMI Description Here" \\' 144b403a55SMatthew Dillonecho ' --instance-id i-ThisInstanceId \\' 154b403a55SMatthew Dillonecho "" 164b403a55SMatthew Dillon 174b403a55SMatthew Dillonif ( "$argv" != "doit" ) then 184b403a55SMatthew Dillon echo "Execute script with 'doit' to really do it" 194b403a55SMatthew Dillon exit 1 204b403a55SMatthew Dillonendif 214b403a55SMatthew Dillon 224b403a55SMatthew Dillonecho "Starting cleanup" 234b403a55SMatthew Dillonsleep 1 244b403a55SMatthew Dillonrm -f ~root/.ssh/{authorized_keys,known_hosts} ~root/.history 254b403a55SMatthew Dillonrm -f /home/ec2-user/.ssh/{authorized_keys,known_hosts} 264b403a55SMatthew Dillonrm -f /home/ec2-user/.history 274b403a55SMatthew Dillontouch /firstboot 284b403a55SMatthew Dillonkillall syslogd 294b403a55SMatthew Dillonsleep 0.1 304b403a55SMatthew Dillonfind /var/log -type f -delete 314b403a55SMatthew Dillontouch /var/log/{auth.log,cron,daemon,maillog,messages,security,userlog} 32*25606b42SSascha Wildnertouch /var/log/wtmpx 334b403a55SMatthew Dillon 344b403a55SMatthew Dillonecho "Cleanup complete" 35