Last active
December 31, 2015 20:29
-
-
Save oreh/8040499 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
setenforce 0 | |
sed -i 's/SELINUX=.*$/SELINUX=disabled/' /etc/selinux/config | |
sed -i 's/ONBOOT=.*$/ONBOOT=yes/' /etc/sysconfig/network-scripts/ifcfg-eth0 | |
yum install git vim gcc make kernel-devel-`uname -r` kernel-headers | |
iptables -F | |
chkconfig iptables off | |
mkdir -p /root/.ssh | |
chmod og-rwx /root/.ssh | |
touch /root/.ssh/authorized_keys | |
cat >> /root/.ssh/authorized_keys << EOF | |
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQCrj72pssAp3W1DO59AiaNUcaVoBP55+500aTle/rm1qzbTZRqlAlIXf3oI45brrhmDPu5nDeO8B5b55lT0gfLWff96uI+o0+BAcvFaWiG60+zJt5cwCqMpLCtTLNYmmnNBXLVluKFhRYtu/EOzWLTKv3cvlzJoGmhzyfnt/bYfpMFwk65QC81kGhQaZfAoeXgvKpUTroi5R1NFfHzgrp+DPLACsrXuPi2FF0ujz2lXYRbpCSDI+BQGUf/RMnFFVWxA+SXs/Q4YrjMEngTHRNmkI5JeJQ9ieD6SS7OxM1UKu+bASdktcMTvG4lLyQz8oFVtKHkE+F+j/CVi0kmOEStx | |
EOF | |
sed -i 's/^Defaults.*requiretty.*$//' /etc/sudoers | |
# mount guest addition | |
mount /dev/cdrom /mnt | |
cd /mnt | |
./VBoxLinuxAdditions.run | |
umount -l /mnt | |
# clean disk spaces | |
echo 'Cleanup bash history' | |
unset HISTFILE | |
[ -f /root/.bash_history ] && rm /root/.bash_history | |
[ -f /home/vagrant/.bash_history ] && rm /home/vagrant/.bash_history | |
echo 'Cleanup log files' | |
find /var/log -type f | while read f; do echo -ne '' > $f; done; | |
echo 'Whiteout root' | |
count=`df --sync -kP / | tail -n1 | awk -F ' ' '{print $4}'`; | |
let count-- | |
dd if=/dev/zero of=/tmp/whitespace bs=1024 count=$count; | |
rm /tmp/whitespace; | |
echo 'Whiteout /boot' | |
count=`df --sync -kP /boot | tail -n1 | awk -F ' ' '{print $4}'`; | |
let count-- | |
dd if=/dev/zero of=/boot/whitespace bs=1024 count=$count; | |
rm /boot/whitespace; | |
swappart=`cat /proc/swaps | tail -n1 | awk -F ' ' '{print $1}'` | |
swapoff $swappart; | |
dd if=/dev/zero of=$swappart; | |
mkswap $swappart; | |
swapon $swappart; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment