3 # vim: ts=4 sw=4 sts=4 et tw=72 :
6 # Handle the occurance where SELINUX is actually disabled
7 SELINUX=$(grep -E '^SELINUX=(disabled|permissive|enforcing)$' /etc/selinux/config)
8 MODE=$(echo "$SELINUX" | cut -f 2 -d '=')
11 echo "************************************"
12 echo "** SYSTEM ENTERING ENFORCING MODE **"
13 echo "************************************"
14 # make sure that the filesystem is properly labelled.
15 # it could be not fully labeled correctly if it was just switched
16 # from disabled, the autorelabel misses some things
17 # skip relabelling on /dev as it will generally throw errors
18 restorecon -R -e /dev /
20 # enable enforcing mode from the very start
23 # configure system for enforcing mode on next boot
24 sed -i 's/SELINUX=permissive/SELINUX=enforcing/' /etc/selinux/config
27 sed -i 's/SELINUX=disabled/SELINUX=permissive/' /etc/selinux/config
30 echo "*******************************************"
31 echo "** SYSTEM REQUIRES A RESTART FOR SELINUX **"
32 echo "*******************************************"
35 echo "*********************************"
36 echo "** SYSTEM IS IN ENFORCING MODE **"
37 echo "*********************************"
41 echo "---> Updating operating system"
43 yum install -y -q deltarpm
46 # add in components we need or want on systems
47 echo "---> Installing base packages"
48 yum install -y -q @base https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
49 # separate group installs from package installs since a non-existing
50 # group with dnf based systems (F21+) will fail the install if such
51 # a group does not exist
52 yum install -y -q unzip xz puppet git perl-XML-XPath wget make
54 # All of our systems require Java (because of Jenkins)
55 # Install all versions of the OpenJDK devel but force 1.7.0 to be the
58 echo "---> Configuring OpenJDK"
59 yum install -y -q 'java-*-openjdk-devel'
61 FACTER_OS=$(/usr/bin/facter operatingsystem)
62 FACTER_OSVER=$(/usr/bin/facter operatingsystemrelease)
65 if [ "$FACTER_OSVER" -ge "21" ]
67 echo "---> not modifying java alternatives as OpenJDK 1.7.0 does not exist"
69 alternatives --set java /usr/lib/jvm/jre-1.7.0-openjdk.x86_64/bin/java
70 alternatives --set java_sdk_openjdk /usr/lib/jvm/java-1.7.0-openjdk.x86_64
74 alternatives --set java /usr/lib/jvm/jre-1.7.0-openjdk.x86_64/bin/java
75 alternatives --set java_sdk_openjdk /usr/lib/jvm/java-1.7.0-openjdk.x86_64
81 # Ignore SELinux since slamming that onto Ubuntu leads to
84 export DEBIAN_FRONTEND=noninteractive
85 cat <<EOF >> /etc/apt/apt.conf
89 allow-change-held-packages "true";
90 allow-downgrades "true";
91 allow-remove-essential "true";
102 echo "---> Updating operating system"
103 apt-get update -qq > /dev/null
104 apt-get upgrade -qq > /dev/null
106 # add in stuff we know we need
107 echo "---> Installing base packages"
108 apt-get install -qq unzip xz-utils puppet git libxml-xpath-perl make wget > /dev/null
111 echo "---> Configuring OpenJDK"
112 apt-get install -qq openjdk-7-jdk > /dev/null
114 # make jdk8 available
115 add-apt-repository -y ppa:openjdk-r/ppa > /dev/null
116 apt-get update -qq > /dev/null
117 # We need to force openjdk-8-jdk to install
118 apt-get install -qq openjdk-8-jdk > /dev/null
120 # make sure that we still default to openjdk 7
121 update-alternatives --set java /usr/lib/jvm/java-7-openjdk-amd64/jre/bin/java
122 update-alternatives --set javac /usr/lib/jvm/java-7-openjdk-amd64/bin/javac
124 # disable unattended upgrades & daily updates
125 echo '---> Disabling automatic daily upgrades'
126 apt-get remove unattended-upgrades
127 if [ -f /usr/bin/systemctl ]
129 systemctl stop apt.systemd.daily
130 systemctl disable apt.systemd.daily
132 /etc/init.d/unattended-upgrades stop
133 update-rc.d -f unattended-upgrades remove
138 # Allow jenkins access to update-alternatives command to switch java version
139 cat <<EOF >/etc/sudoers.d/89-jenkins-user-defaults
140 Defaults:jenkins !requiretty
141 jenkins ALL = NOPASSWD: /usr/bin/update-alternatives
144 # Do any Distro specific installations here
145 echo "Checking distribution"
146 FACTER_OS=$(/usr/bin/facter operatingsystem)
149 echo "---> $FACTER_OS found"
150 echo "No extra steps for $FACTER_OS"
155 echo "---> Attempting to detect OS"
156 # upstream cloud images use the distro name as the initial user
157 ORIGIN=$(if [ -e /etc/redhat-release ]
166 fedora|centos|redhat)
167 echo "---> RH type system detected"
171 echo "---> Ubuntu system detected"
175 echo "---> Unknown operating system"
179 # execute steps for all systems