cat << 'EOF' >> /usr/local/bin/apt-get
#!/bin/bash
+TTY=$(tty)
+test -z "$TTY" && TERM=dumb
+
i=0
tput sc
-while [ fuser /var/lib/dpkg/lock >/dev/null 2>&1 || fuser /var/lib/apt/lists/lock >/dev/null 2>&1 ]; do
+LOCKFILES="/var/lib/dpkg/lock /var/lib/apt/lists/lock /var/cache/apt/archives/lock"
+while fuser ${LOCKFILES} >/dev/null 2>&1 ; do
case $(($i % 4)) in
0 ) j="-" ;;
1 ) j="\\" ;;
((i=i+1))
done
-/usr/bin/apt-get "$@"
+if [ $i==0 ]
+then
+ /usr/bin/apt-get "$@"
+else
+ sleep 1
+ exec /usr/local/bin/apt-get "$@"
+fi
EOF
chmod +x /usr/local/bin/apt-get
}
+opensuse_systems() {
+ # SELinux?
+
+ # Replacing cloud.cfg, it's not supported by cloud-init
+ cp /etc/cloud/cloud.cfg /etc/cloud/cloud.cfg.orig
+
+ # Clean and add repos and refresh
+ zypper clean -a
+ zypper --non-interactive --gpg-auto-import-keys ar \
+ http://download.opensuse.org/update/leap/42.3/oss/openSUSE:Leap:42.3:Update.repo
+ zypper --gpg-auto-import-keys ref
+ zypper --non-interactive --gpg-auto-import-keys ar \
+ http://download.opensuse.org/repositories/Cloud:/Tools/openSUSE_Leap_42.3/ Cloud:Tools.repo
+
+ # Add in components we need or want on systems
+ echo "---> Installing base packages"
+ zypper -n install unzip xz puppet perl-XML-XPath
+
+ # Instlal tools
+ echo "---> Installing tools packages"
+ zypper -n install git git-review wget libstdc++-devel ruby-devel
+
+ # All of our systems require Java (because of Jenkins)
+ echo "---> Configuring OpenJDK"
+ zypper -n install 'java-*-openjdk-devel'
+
+ # Needed to parse OpenStack commands used by infra stack commands
+ # to initialize Heat template based systems.
+ zypper -n install jq
+
+}
+
all_systems() {
# Allow jenkins access to update-alternatives command to switch java version
cat <<EOF >/etc/sudoers.d/89-jenkins-user-defaults
jenkins ALL = NOPASSWD: /usr/bin/update-alternatives
EOF
+ # Enable Hugepages
+ puppet module install thias-sysctl --version 1.0.6
+ puppet apply -e "sysctl {'vm.nr_hugepages': value => '128'}"
+ puppet apply -e "file { '/mnt/huge': ensure => directory }"
+ puppet apply -e "mount { '/mnt/huge': ensure => mounted, atboot => true, \
+ device => 'none', fstype => 'hugetlbfs', options => 'mode=01777' }"
+
# Do any Distro specific installations here
echo "Checking distribution"
FACTER_OS=$(/usr/bin/facter operatingsystem)
ORIGIN=$(if [ -e /etc/redhat-release ]
then
echo redhat
- else
+ else [ -e /etc/os-release ]
+ DIST="$(grep "\<ID\>" /etc/os-release)"
+ if [ $DIST = "ID=ubuntu" ]
+ then
echo ubuntu
+ else
+ echo opensuse
+ fi
fi)
-#ORIGIN=$(logname)
case "${ORIGIN}" in
fedora|centos|redhat)
echo "---> Ubuntu system detected"
ubuntu_systems
;;
+ opensuse)
+ echo "---> openSuSE system detected"
+ opensuse_systems
+ ;;
*)
echo "---> Unknown operating system"
;;