1#!/bin/bash 2 3set -ex 4 5install_ubuntu() { 6 apt-get update 7 8 # Cleanup 9 apt-get autoclean && apt-get clean 10 rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* 11} 12 13install_centos() { 14 # Need EPEL for many packages we depend on. 15 # See http://fedoraproject.org/wiki/EPEL 16 yum --enablerepo=extras install -y epel-release 17 18 # Cleanup 19 yum clean all 20 rm -rf /var/cache/yum 21 rm -rf /var/lib/yum/yumdb 22 rm -rf /var/lib/yum/history 23} 24 25# Install base packages depending on the base OS 26ID=$(grep -oP '(?<=^ID=).+' /etc/os-release | tr -d '"') 27case "$ID" in 28 ubuntu) 29 install_ubuntu 30 ;; 31 centos) 32 install_centos 33 ;; 34 *) 35 echo "Unable to determine OS..." 36 exit 1 37 ;; 38esac 39