howto

OpenNode OS AWS image

Creating OpenNode OS AMI

# Revert some ComodIT image stuff back
ssh -i .ssh/awskey.pem ec2-user@host
sudo sed -i 's/#PermitRootLogin yes/PermitRootLogin yes/g' /etc/ssh/sshd_config
sudo sed -i "s|Banner /etc/ssh/sshd_banner|#Banner none|" /etc/ssh/sshd_config
sudo sed -i 's/disable_root: 1/disable_root: 0/' /etc/cloud/cloud.cfg
sudo sed -i 's/user: ec2-user/user: root/' /etc/cloud/cloud.cfg
sudo rm -f /etc/ssh/sshd_banner
sudo service sshd reload
sudo cp /home/ec2-user/.ssh/authorized_keys /root/.ssh/authorized_keys



# Re-login as root over ssh
ssh -i .ssh/awskey.pem root@host
userdel -r ec2-user
sed -i '/ec2-user/d' /etc/sudoers
rm -f /etc/yum.repos.d/epel*

# Do OpenNode conversion
yum install -y wget
wget -q -O - http://opennodecloud.com/download/centos6-to-opennode6.sh | bash
sed -i 's/kernel/vzkernel/' /etc/sysconfig/kernel

# Merge /vz into /storage
mkdir -p /storage/local/vz
cd /vz
mv -v * /storage/local/vz/
rmdir /vz
cd / && ln -s /storage/local/vz

reboot

AMI cleanup

# Remove test containers
for i in vzlist -H -a -o ctid; do echo "Stopping: $i"; vzctl stop $i --fast; vzctl destroy $i; done

# Clean up test CT configuration files
rm -f /etc/vz/conf/*.destroyed

# Clean up downloaded OVZ templates
rm -f /storage/local/openvz/*.tar*
rm -f /storage/local/openvz/unpacked/*
rm -f /vz/template/cache/*

# Remove ssh keys and lock passwords
rm -f /root/.ssh/authorized_keys
passwd -l root

# Reset log files
cd /var/log/
for i in boot.log btmp cron dmesg dmesg.old dracut.log lastlog libvirt/libvirtd.log maillog messages opennode-tui.log salt/minion secure vzctl.log wtmp yum.log; do echo ''>$i; done

# Clean up shell history
rm -rf /root/.mc
history -c

# shutdown 
shutdown -h now