Skip to content

Commit

Permalink
use new template of packers
Browse files Browse the repository at this point in the history
  • Loading branch information
sawanoboly committed Feb 17, 2016
1 parent 60e63b8 commit 9a28705
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 14 deletions.
6 changes: 3 additions & 3 deletions Vagrantfile
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,15 @@ Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
aws.instance_type = 'c3.large'
case ENV['AWS_REGION']
when 'ap-northeast-1'
aws.ami = 'ami-9a2fb89a' # Amazon Linux AMI 2015.09.0 (HVM) SSD
aws.ami = 'ami-383c1956' # Amazon Linux AMI 2015.09.1 (HVM) SSD
when 'us-east-1'
aws.ami = 'ami-e3106686' # Amazon Linux AMI 2015.09.0 (HVM) SSD
aws.ami = 'ami-60b6c60a' # Amazon Linux AMI 2015.09.1 (HVM) SSD
else
raise "Unsupported region #{ENV['AWS_REGION']}"
end

aws.tags = {
'Name' => 'Moodle 2.9.3 (Develop)'
'Name' => "Moodle #{ENV['PRODUCT_VERSION']} (Developed by #{ENV['USER']})"
}
override.ssh.username = "ec2-user"
override.ssh.private_key_path = ENV['AWS_EC2_KEYPASS']
Expand Down
41 changes: 31 additions & 10 deletions cleanup.sh
Original file line number Diff line number Diff line change
@@ -1,22 +1,43 @@
#!/usr/bin/env bash

set -ex
sudo sync
sleep 5 # In some case, crontab was not updated...

# yum clean
sudo yum clean all

sudo rm -rf /tmp/*
sudo rm -rf /vagrant
sudo rm -f /etc/ssh/ssh_host_*
# erase logs
cd /var/log
sudo find /var/log/ -type f -name '*.log' -exec sudo cp /dev/null {} \;
sudo cp /dev/null /var/log/syslog
sudo find /var/log/ -type f -exec sudo cp /dev/null {} \;
sudo rm -rf /var/log/nginx/*
sudo rm -rf /var/log/php-fpm/*
sudo rm -rf /var/log/httpd/*
sudo rm -f /var/lib/mysql/ib_logfile*

# erase mails
sudo find /var/spool/mail/ -type f -exec sudo cp /dev/null {} \;

yes | sudo cp /dev/null /root/.ssh/authorized_keys
yes | sudo cp /dev/null /root/.bash_history
# erase authorized_keys, command history...
sudo rm -f /etc/ssh/ssh_host_*
sudo cp /dev/null /root/.ssh/authorized_keys
sudo cp /dev/null /root/.bash_history
sudo cp /dev/null /root/.mysql_history
if [ -d /home/ec2-user ]; then
yes | cp /dev/null /home/ec2-user/.ssh/authorized_keys
yes | cp /dev/null /home/ec2-user/.bash_history
cp /dev/null /home/ec2-user/.ssh/authorized_keys
cp /dev/null /home/ec2-user/.bash_history
if [ -f /home/ec2-user/.mysql_history ]; then
sudo chown ec2-user.ec2-user /home/ec2-user/.mysql_history
cp /dev/null /home/ec2-user/.mysql_history
fi
fi
history -c

sudo rm -rf /home/ec2-user/.composer
sudo rm -rf /tmp/*
sudo rm -rf /var/tmp/php/session/*
sudo rm -rf /var/www/vhosts/*
sudo rm -rf /var/cache/nginx/proxy_cache/*
sudo rm -rf /var/cache/nginx/proxy_temp/*
sudo rm -rf /vagrant
sudo rm -rf /var/chef
sudo rm -f /etc/ssh/ssh_host_*
2 changes: 1 addition & 1 deletion packer_ec2.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"ssh_username": "ec2-user",
"ssh_timeout": "10m",
"ssh_pty" : true,
"ami_name": "Moodle 2.9.3 {{timestamp}}"
"ami_name": "Moodle {{user `product_version`}} {{timestamp}}"
}
],

Expand Down

0 comments on commit 9a28705

Please sign in to comment.