Skip to content

Instantly share code, notes, and snippets.

@calum-github
Created February 5, 2015 01:50
Show Gist options
  • Select an option

  • Save calum-github/d5670cbb33f3d557cb3a to your computer and use it in GitHub Desktop.

Select an option

Save calum-github/d5670cbb33f3d557cb3a to your computer and use it in GitHub Desktop.
centos bsdpy prep
#!/bin/bash
######################################################################################
# #
# Author: Calum Hunter #
# Date: 29/01/2015 #
# Version: 0.4 #
# Purpose: This script will go through and setup a base CentOS 7 minimal OS #
# install so that it is ready to be made into a VM template or cloned. #
# It will also install the first_boot_setup.sh script so that #
# the VM will configure itself as required on firstboot #
# #
######################################################################################
### Useage
#
# After creating a new minimal VM with CentOS 7, and creating only a root user account
# No additional packackages or configuration is to be done - this script will do it
# Attach the iso containing this script and run it. Simples
#
docker_rego_server=192.168.168.168
## Main function which runs our sub functions enable or disable each item here
main(){
# Do our initial pre setup stuff here
system_setup # Disable firewall, disable selinux
set_yum_proxy # Set proxy for yum
install_base_packages # Install docker, bind-utils, net-tools, wget
docker_upgrade # Upgrade docker from the version supplied by yum to the latest binary from docker
docker_setup # Start docker service, configure to start on boot, set proxy servers and insecure private repo's
docker_pull # Pull down BSDPy-docker, munkirepo-docker, nbi-data-only docker images
disable_NM # stop network manager and disable it
}
docker_upgrade(){
echo "*** Upgrading Docker to latest version ***"
export http_proxy=$proxy
export https_proxy=$proxy
wget https://get.docker.com/builds/Linux/x86_64/docker-latest -O /root/docker
mv /usr/bin/docker /usr/bin/docker_old_version
mv /root/docker /usr/bin/docker
chmod +x /usr/bin/docker
}
docker_pull(){
echo "*** Pulling latest Netboot docker images down"
docker pull hunty1/bsdpydocker:latest
docker pull hunty1/munki-docker:latest
docker pull ${docker_rego_server}:5000/nbi-data-only:latest
}
docker_setup(){ # Configure Docker Proxy settings
echo "*** Configuring Docker ***"
service docker start
chkconfig docker on
echo "*** Enabling insecure private registry access for Docker ***"
sed -i '/^OPTIONS=--/d' /etc/sysconfig/docker
echo "OPTIONS=--insecure-registry ${docker_rego_server}:5000 -H fd://" >> /etc/sysconfig/docker
service docker restart
}
install_base_packages(){ # Install base packages
echo "*** Updating the system ***"
yum -y update
echo "*** Installing base packages: bind-utils, net-tools, docker from yum repo ***"
yum -y install docker bind-utils net-tools nano wget samba samba-client openldap-clients rsync
echo "*** Base packages installed ***"
echo "*** installing puppet agent ***"
export http_proxy=$proxy:$proxy_port
export https_proxy=$proxy:$proxy_port
rpm -ivh http://yum.puppetlabs.com/puppetlabs-release-el-7.noarch.rpm
yum -y install puppet
}
system_setup(){ # Do some basic system setup tasks
echo "*** Stopping and disabling Firewalld ***"
systemctl stop firewalld && systemctl disable firewalld
echo "*** Firewalld disabled ***"
echo "*** Disabling SELinux ***"
sed -i -e 's/SELINUX=enforcing/SELINUX=disabled/g' /etc/selinux/config
echo "*** Creating storage directory for DS_Repo"
mkdir -p /DS_Repo
echo "*** Creating storage repo for Munki ***"
mkdir -p /munki_repo && chmod -R 777 /munki_repo
}
disable_NM(){ # Disable Network Manager so it doesn't interfere with our static IP
echo "*** Disabling Network Manager ***"
/bin/systemctl stop NetworkManager.service
/bin/systemctl disable NetworkManager.service
echo "*** Network Manager: - Disabled ***"
}
#---------------Script action-------------------#
main
#-----------------------------------------------#
exit 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment