Last active
December 22, 2015 16:28
-
-
Save joekiller/6499137 to your computer and use it in GitHub Desktop.
centos6 vagrant
This file contains 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
#!/bin/bash | |
#This script will prep a centos6 box for vagrant box packaging | |
cat << EOF | tee /etc/sysconfig/network-scripts/ifcfg-eth0 | |
DEVICE="eth0" | |
BOOTPROTO="dhcp" | |
NM_CONTROLLED="yes" | |
ONBOOT="yes" | |
TYPE="Ethernet" | |
EOF | |
service network restart | |
yum -y update | |
yum -y install sudo | |
yum -y groupinstall "Development Tools" | |
useradd vagrant | |
groupadd admin | |
echo vagrant | passwd --stdin vagrant | |
usermod -a -G admin vagrant | |
# Setup sudo privileges | |
sed -i -e's/^Defaults.*requiretty/#Defaults requiretty/' /etc/sudoers | |
echo %admin ALL=NOPASSWD: ALL | tee -a /etc/sudoers | |
echo Defaults env_keep += \"SSH_AUTH_SOCK\" | tee -a /etc/sudoers | |
# Setup SSH permissions for vagrant | |
mkdir -p /home/vagrant/.ssh | |
cd /home/vagrant/.ssh | |
curl -O https://raw.github.com/mitchellh/vagrant/master/keys/vagrant.pub | |
mv vagrant.pub authorized_keys | |
chown -R vagrant:vagrant /home/vagrant/.ssh | |
chmod 700 /home/vagrant/.ssh | |
chmod 600 /home/vagrant/.ssh/authorized_keys | |
sed -i -e's/^#UseDNS yes/UseDNS no/' /etc/ssh/sshd_config | |
sed -i -e's/^#PubkeyAuthentication yes/PubkeyAuthentication yes/' /etc/ssh/sshd_config | |
sed -i -e's/^#AuthorizedKeysFile.*\.ssh\/authorized_keys/AuthorizedKeysFile \.ssh\/authorized_keys/' /etc/ssh/sshd_config | |
# Reboot and then install updates and guest additions | |
echo Reboot the server and then install the virtual guest addons | |
echo shutdown -r 0 | |
echo yum -y update | |
echo mount /dev/cdrom /media | |
echo /media/VBoxLinuxAdditions.run | |
echo umount /media | |
echo shutdown -h 0 | |
# Package the file using | |
# vagrant package --base vagrant-centos63-nochef --output centos63-base-nochef.box | |
# vagrant box add centos63-nochef centos63-base-nochef.box |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment