Check distro name from DISTRO_NAME

Use default 'DISTRO_NAME' variable for check which distro is use
for current image build

Change-Id: Ieba71733fbcd554a1c7416efb0c4b740939d06a8
Closes-bug: #1436807
This commit is contained in:
Denis Egorenko 2015-03-26 21:45:30 +04:00
parent 0a9336265f
commit db50f5ba97
19 changed files with 75 additions and 103 deletions

View File

@ -5,9 +5,7 @@ if [ "${DIB_DEBUG_TRACE:-0}" -gt 0 ]; then
fi
set -e
distro=$(lsb_release -is)
if [ "$distro" = "Fedora" ]; then
if [ "$DISTRO_NAME" = "fedora" ]; then
install-packages iptables-services
fi

View File

@ -5,9 +5,7 @@ if [ "${DIB_DEBUG_TRACE:-0}" -gt 0 ]; then
fi
set -e
distro=$(lsb_release -is)
if [ "$distro" = "Fedora" ]; then
if [ "$DISTRO_NAME" = "fedora" ]; then
install-packages iptables-services
fi

View File

@ -8,18 +8,17 @@ if [ "${DIB_DEBUG_TRACE:-0}" -gt 0 ]; then
set -x
fi
distro=$(lsb_release -is || :)
if [ "$distro" != "Ubuntu" ]; then
echo "Distro $distro not supported by CDH. Exiting."
if [ "$DISTRO_NAME" != "ubuntu" ]; then
echo "Distro $DISTRO_NAME not supported by CDH. Exiting."
exit 1
fi
echo "Hadoop CDH setup begins for $distro"
echo "Hadoop CDH setup begins for $DISTRO_NAME"
tmp_dir=/tmp/hadoop
echo "Creating hadoop user & group"
case "$distro" in
Ubuntu )
case "$DISTRO_NAME" in
ubuntu )
addgroup hadoop
adduser --ingroup hadoop --disabled-password --gecos GECOS hadoop
adduser hadoop sudo
@ -43,8 +42,8 @@ Pin: origin "archive.cloudera.com"
Pin-Priority: 800
EOF
case "$distro" in
Ubuntu )
case "$DISTRO_NAME" in
ubuntu )
dpkg -i $tmp_dir/cdh4-repository_1.0_all.deb
curl -s http://archive.cloudera.com/cdh4/ubuntu/precise/amd64/cdh/archive.key | sudo apt-key add -
sudo apt-get update
@ -61,8 +60,8 @@ echo "Pre-configuring Hadoop"
JAVA_HOME=$(find $TARGET_ROOT$JAVA_TARGET_LOCATION/ -maxdepth 1 -name "jdk*")
if [ -z "$JAVA_HOME" ]; then
case "$distro" in
Ubuntu)
case "$DISTRO_NAME" in
ubuntu)
JAVA_HOME=$(readlink -e /usr/bin/java | sed "s:bin/java::")
;;
esac

View File

@ -7,9 +7,8 @@ if [ "${DIB_DEBUG_TRACE:-0}" -gt 0 ]; then
set -x
fi
distro=$(lsb_release -is || :)
case "$distro" in
Ubuntu )
case "$DISTRO_NAME" in
ubuntu )
# pietro: small hack to fix install problems on ubuntu
# the CDH package contains a broken symlink instead of the log4j jar file
# these 4 lines should go away once Cloudera fixes the package

View File

@ -5,7 +5,7 @@ if [ "${DIB_DEBUG_TRACE:-0}" -gt 0 ]; then
fi
set -eu
if [ $(lsb_release -is) = 'Ubuntu' ]; then
if [ "$DISTRO_NAME" = "ubuntu" ]; then
export DEBIAN_FRONTEND=noninteractive
export RUNLEVEL=1
fi
@ -52,6 +52,6 @@ if [ $DIB_CDH_VERSION != "5.0" ]; then
sqoop2
fi
if [ $(lsb_release -is) = 'Ubuntu' ]; then
if [ "$DISTRO_NAME" = "ubuntu" ]; then
unset RUNLEVEL
fi

View File

@ -21,7 +21,7 @@ hue \
oozie \
postgresql
do
if [ $(lsb_release -is) = 'Ubuntu' ]; then
if [ "$DISTRO_NAME" = "ubuntu" ]; then
update-rc.d -f $i remove
else
chkconfig $i off
@ -35,7 +35,7 @@ if [ $DIB_CDH_VERSION != "5.0" ]; then
solr-server \
spark-history-server
do
if [ $(lsb_release -is) = 'Ubuntu' ]; then
if [ "$DISTRO_NAME" = "ubuntu" ]; then
update-rc.d -f $i remove
else
chkconfig $i off

View File

@ -4,12 +4,9 @@ if [ "${DIB_DEBUG_TRACE:-0}" -gt 0 ]; then
set -x
fi
distro=$(lsb_release -is)
function add_repo_5_0_0 {
case $distro in
Ubuntu )
case $DISTRO_NAME in
ubuntu )
# Add repository with postgresql package (it's dependency of cloudera packages)
# Base image doesn't contain this repo
echo -e 'deb http://nova.clouds.archive.ubuntu.com/ubuntu/ precise universe multiverse main' >> /etc/apt/sources.list
@ -27,7 +24,7 @@ function add_repo_5_0_0 {
apt-get update
;;
CentOS | RedHatEnterpriseServer )
centos | rhel )
echo '[cloudera-cdh5]' > /etc/yum.repos.d/cloudera-cdh5.repo
echo "name=Cloudera's Distribution for Hadoop, Version 5" >> /etc/yum.repos.d/cloudera-cdh5.repo
echo 'baseurl=http://archive.cloudera.com/cdh5/redhat/6/x86_64/cdh/5.0.0/' >> /etc/yum.repos.d/cloudera-cdh5.repo
@ -45,8 +42,8 @@ function add_repo_5_0_0 {
}
function add_repo_5_3_0 {
case $distro in
Ubuntu )
case $DISTRO_NAME in
ubuntu )
# Add repository with postgresql package (it's dependency of cloudera packages)
# Base image doesn't contain this repo
echo -e 'deb http://nova.clouds.archive.ubuntu.com/ubuntu/ precise universe multiverse main' >> /etc/apt/sources.list
@ -64,7 +61,7 @@ function add_repo_5_3_0 {
apt-get update
;;
CentOS | RedHatEnterpriseServer )
centos | rhel )
echo '[cloudera-cdh5]' > /etc/yum.repos.d/cloudera-cdh5.repo
echo "name=Cloudera's Distribution for Hadoop, Version 5" >> /etc/yum.repos.d/cloudera-cdh5.repo
echo 'baseurl=http://archive.cloudera.com/cdh5/redhat/6/x86_64/cdh/5.3.0/' >> /etc/yum.repos.d/cloudera-cdh5.repo

View File

@ -7,9 +7,7 @@ set -eu
echo "START: installing MapR core dependencies"
DISTRO=$(lsb_release -is || :)
if [ "$DISTRO" = "Ubuntu" ]; then
if [ "$DISTRO_NAME" = "ubuntu" ]; then
# Required for libicu48
cat >> /etc/apt/sources.list.d/security_repo.list << EOF
deb http://security.ubuntu.com/ubuntu precise-security main
@ -67,7 +65,7 @@ EOF
watchdog \
zlib1g-dev \
zip
elif [ "$DISTRO" = 'CentOS' -o "$DISTRO" = 'RedHatEnterpriseServer' ]; then
elif [ "$DISTRO_NAME" = "centos" -o "$DISTRO_NAME" = "rhel" ]; then
install-packages cdparanoia-libs \
cups \
cups-libs \

View File

@ -7,8 +7,6 @@ set -eu
echo "START: installing Scala"
DISTRO=$(lsb_release -is || :)
#Current available version
DEF_VERSION="2.11.2"
@ -30,11 +28,11 @@ PKG=scala-${VERSION}
URL="http://downloads.typesafe.com/scala/${VERSION}"
if [ "$DISTRO" = "Ubuntu" ]; then
if [ "$DISTRO_NAME" = "ubuntu" ]; then
wget -N ${URL}/${PKG}.deb
dpkg -i ${PKG}.deb
rm ${PKG}.deb
elif [ "$DISTRO" = 'CentOS' -o "$DISTRO" = 'RedHatEnterpriseServer' ]; then
elif [ "$DISTRO_NAME" = "centos" -o "$DISTRO_NAME" = "rhel" ]; then
rpm -Uhv ${URL}/${PKG}.rpm
fi

View File

@ -11,12 +11,10 @@ install-packages curl
MAPR_REPO_DIR=/opt/mapr-repository/core
DISTRO=$(lsb_release -is || :)
if [ "$DISTRO" = "Ubuntu" ]; then
MAPR_REPO_URL=${DIB_MAPR_CORE_DEB_REPO:-"http://package.mapr.com/releases/v"${DIB_MAPR_VERSION}"/ubuntu/mapr-v"${DIB_MAPR_VERSION}"GA.deb.tgz"}
elif [ "$DISTRO" = 'CentOS' -o "$DISTRO" = 'RedHatEnterpriseServer' ]; then
MAPR_REPO_URL=${DIB_MAPR_CORE_RPM_REPO:-"http://package.mapr.com/releases/v"${DIB_MAPR_VERSION}"/redhat/mapr-v"${DIB_MAPR_VERSION}"GA.rpm.tgz"}
if [ "$DISTRO_NAME" = "ubuntu" ]; then
MAPR_REPO_URL=${DIB_MAPR_CORE_DEB_REPO:-"http://package.mapr.com/releases/v${DIB_MAPR_VERSION}/ubuntu/mapr-v${DIB_MAPR_VERSION}GA.deb.tgz"}
elif [ "$DISTRO_NAME" = "centos" -o "$DISTRO_NAME" = "rhel" ]; then
MAPR_REPO_URL=${DIB_MAPR_CORE_RPM_REPO:-"http://package.mapr.com/releases/v${DIB_MAPR_VERSION}/redhat/mapr-v${DIB_MAPR_VERSION}GA.rpm.tgz"}
else
echo "Unknown distribution"
exit 1
@ -37,21 +35,21 @@ tar -zxf ${MAPR_REPO_DIR}/mapr-v${DIB_MAPR_VERSION}GA.tgz -C ${MAPR_REPO_DIR}
echo "Removing MapR repository archive"
rm -f ${MAPR_REPO_DIR}/mapr-v${DIB_MAPR_VERSION}GA.tgz
if [ "$DISTRO" = "Ubuntu" ]; then
if [ "$DISTRO_NAME" = "ubuntu" ]; then
mkdir -p "${MAPR_REPO_DIR}"/dists/binary/optional/binary-amd64
cd ${MAPR_REPO_DIR}
dpkg-scanpackages -m . /dev/null | gzip -9c > dists/binary/optional/binary-amd64/Packages.gz
elif [ "$DISTRO" = 'CentOS' -o "$DISTRO" = 'RedHatEnterpriseServer' ]; then
elif [ "$DISTRO_NAME" = "centos" -o "$DISTRO_NAME" = "rhel" ]; then
createrepo "${MAPR_REPO_DIR}"
fi
echo "Adding MapR repository"
if [ "$DISTRO" = "Ubuntu" ]; then
if [ "$DISTRO_NAME" = "ubuntu" ]; then
cat >> /etc/apt/sources.list.d/maprtech.list << EOF
deb [arch=amd64] file://${MAPR_REPO_DIR} binary optional
EOF
elif [ "$DISTRO" = 'CentOS' -o "$DISTRO" = 'RedHatEnterpriseServer' ]; then
elif [ "$DISTRO_NAME" = "centos" -o "$DISTRO_NAME" = "rhel" ]; then
cat >> /etc/yum.repos.d/maprtech.repo << EOF
[mapr-core]
name=MapR Technologies

View File

@ -9,18 +9,16 @@ echo "START: installing MapR ecosystem repository"
MAPR_REPO_DIR=/opt/mapr-repository/ecosystem
DISTRO=$(lsb_release -is || :)
RPM_REPO=${DIB_MAPR_ECO_RPM_REPO:-}
DEB_REPO=${DIB_MAPR_ECO_DEB_REPO:-}
if [ "$DISTRO" = "Ubuntu" ]; then
if [ "$DISTRO_NAME" = "ubuntu" ]; then
if [ "$DIB_MAPR_VERSION" = "3.1.1" ]; then
MAPR_REPO_URL=${DIB_MAPR_ECO_DEB_REPO:-"http://package.mapr.com/releases/ecosystem/ubuntu/"}
elif [ "$DIB_MAPR_VERSION" = "4.0.1" ]; then
MAPR_REPO_URL=${DIB_MAPR_ECO_DEB_REPO:-"http://package.mapr.com/releases/ecosystem-4.x/ubuntu/"}
fi
elif [ "$DISTRO" = 'CentOS' -o "$DISTRO" = 'RedHatEnterpriseServer' ]; then
elif [ "$DISTRO_NAME" = "centos" -o "$DISTRO_NAME" = "rhel" ]; then
if [ "$DIB_MAPR_VERSION" = "3.1.1" ]; then
MAPR_REPO_URL=${DIB_MAPR_ECO_RPM_REPO:-"http://package.mapr.com/releases/ecosystem/redhat/"}
elif [ "$DIB_MAPR_VERSION" = "4.0.1" ]; then
@ -61,21 +59,21 @@ SCRIPT_FILE="/tmp/versions.py"
SPEC_FILE="/opt/mapr-repository/version-spec"
python ${SCRIPT_FILE} --path ${MAPR_REPO_DIR} --spec-file ${SPEC_FILE} | xargs sudo rm -f || echo "Operation failed"
if [ "$DISTRO" = "Ubuntu" ]; then
if [ "$DISTRO_NAME" = "ubuntu" ]; then
mkdir -p "${MAPR_REPO_DIR}"/dists/binary/optional/binary-amd64
cd ${MAPR_REPO_DIR}
dpkg-scanpackages -m . /dev/null | gzip -9c > dists/binary/optional/binary-amd64/Packages.gz
elif [ "$DISTRO" = 'CentOS' -o "$DISTRO" = 'RedHatEnterpriseServer' ]; then
elif [ "$DISTRO_NAME" = "centos" -o "$DISTRO_NAME" = "rhel" ]; then
createrepo "${MAPR_REPO_DIR}"
fi
echo "Adding MapR repository"
if [ "$DISTRO" = "Ubuntu" ]; then
if [ "$DISTRO_NAME" = "ubuntu" ]; then
cat >> /etc/apt/sources.list.d/maprtech.list << EOF
deb [arch=amd64] file://${MAPR_REPO_DIR} binary optional
EOF
elif [ "$DISTRO" = 'CentOS' -o "$DISTRO" = 'RedHatEnterpriseServer' ]; then
elif [ "$DISTRO_NAME" = "centos" -o "$DISTRO_NAME" = "rhel" ]; then
cat >> /etc/yum.repos.d/maprtech.repo << EOF
[mapr-ecosystem]
name=MapR Technologies

View File

@ -5,9 +5,7 @@ if [ "${DIB_DEBUG_TRACE:-0}" -gt 0 ]; then
fi
set -eu
DISTRO=$(lsb_release -is || :)
if [ "$DISTRO" = 'CentOS' -o "$DISTRO" = 'RedHatEnterpriseServer' ]; then
if [ "$DISTRO_NAME" = "centos" -o "$DISTRO_NAME" = "rhel" ]; then
sed '/^Defaults requiretty*/ s/^/#/' -i /etc/sudoers
fi

View File

@ -5,10 +5,8 @@ if [ "${DIB_DEBUG_TRACE:-0}" -gt 0 ]; then
fi
set -eu
DISTRO=$(lsb_release -is || :)
if [ "$DISTRO" = "Ubuntu" ]; then
if [ "$DISTRO_NAME" = "ubuntu" ]; then
apt-get update
elif [ "$DISTRO" = 'CentOS' -o "$DISTRO" = 'RedHatEnterpriseServer' ]; then
elif [ "$DISTRO_NAME" = "centos" -o "$DISTRO_NAME" = "rhel" ]; then
yum clean all && yum repolist
fi

View File

@ -25,11 +25,11 @@ function find_java_home {
JAVA_HOME=$(find $TARGET_ROOT$JAVA_TARGET_LOCATION/ -maxdepth 1 -name "jdk*")
if [ -z "$JAVA_HOME" ]; then
case "$distro" in
Ubuntu )
case "$DISTRO_NAME" in
ubuntu )
JAVA_HOME=$(readlink -e /usr/bin/java | sed "s:bin/java::")
;;
Fedora | RedHatEnterpriseServer | CentOS )
fedora | rhel | centos )
JAVA_HOME=$(rpm --eval '%{?java_home}')
;;
esac
@ -37,22 +37,22 @@ function find_java_home {
}
function install_hadoop_v1 {
case "$distro" in
Ubuntu )
case "$DISTRO_NAME" in
ubuntu )
package="hadoop_$DIB_HADOOP_VERSION-1_x86_64.deb"
;;
Fedora | RedHatEnterpriseServer | CentOS )
fedora | rhel | centos )
package="hadoop-$DIB_HADOOP_VERSION-1.x86_64.rpm"
;;
esac
download_hadoop_package
case "$distro" in
Ubuntu )
case "$DISTRO_NAME" in
ubuntu )
dpkg -i $tmp_dir/$package
;;
Fedora | RedHatEnterpriseServer | CentOS )
fedora | rhel | centos )
if [ $(lsb_release -rs) -ge '19' ]; then
rpm -i $tmp_dir/$package --relocate /usr=/usr --replacefiles
else
@ -148,23 +148,22 @@ EOF
ln -s ${HADOOP_HOME}/share/hadoop/tools/lib/hadoop-openstack-${DIB_HADOOP_VERSION}.jar ${HADOOP_HOME}/share/hadoop/common/lib/
}
distro=$(lsb_release -is || :)
if [ ! "$distro" == "Fedora" -a ! "$distro" == "Ubuntu" -a ! "$distro" == "RedHatEnterpriseServer" -a ! "$distro" == "CentOS" ]; then
echo "Unknown distro: $distro. Exiting."
if [ ! "$DISTRO_NAME" == "fedora" -a ! "$DISTRO_NAME" == "ubuntu" -a ! "$DISTRO_NAME" == "rhel" -a ! "$DISTRO_NAME" == "centos" ]; then
echo "Unknown distro: $DISTRO_NAME. Exiting."
exit 1
fi
echo "Hadoop setup begins for $distro"
echo "Hadoop setup begins for $DISTRO_NAME"
tmp_dir=/tmp/hadoop
echo "Creating hadoop user & group"
case "$distro" in
Ubuntu )
case "$DISTRO_NAME" in
ubuntu )
addgroup hadoop
adduser --ingroup hadoop --disabled-password --gecos GECOS hadoop
adduser hadoop sudo
;;
Fedora | RedHatEnterpriseServer | CentOS )
fedora | rhel | centos )
adduser -G adm,wheel hadoop
;;
esac
@ -180,7 +179,7 @@ fi
echo "Applying firstboot script"
RC_SCRIPT_DIR=""
if [ "$distro" == "Ubuntu" ]; then
if [ "$DISTRO_NAME" == "ubuntu" ]; then
# File '/etc/rc.local' may not exist
if [ -f "/etc/rc.local" ]; then
mv /etc/rc.local /etc/rc.local.old

View File

@ -6,8 +6,6 @@ if [ "${DIB_DEBUG_TRACE:-0}" -gt 0 ]; then
fi
set -e
distro=$(lsb_release -is || :)
: ${JAVA_TARGET_LOCATION:="/usr/java"}
# NOTE: $(dirname $0) is read-only, use space under $TARGET_ROOT
@ -45,8 +43,8 @@ else
export JAVA_HOME=$JAVA_TARGET_LOCATION/$JAVA_NAME
export PATH=\$PATH:$JAVA_TARGET_LOCATION/$JAVA_NAME/bin
EOF
case "$distro" in
Ubuntu )
case "$DISTRO_NAME" in
ubuntu )
echo "Setting up alternatives for Java"
update-alternatives --install "/usr/bin/java" "java" "$JAVA_TARGET_LOCATION/$JAVA_NAME/bin/java" 1
update-alternatives --install "/usr/bin/javac" "javac" "$JAVA_TARGET_LOCATION/$JAVA_NAME/bin/javac" 1
@ -56,7 +54,7 @@ EOF
update-alternatives --set javac $JAVA_TARGET_LOCATION/$JAVA_NAME/bin/javac
update-alternatives --set javaws $JAVA_TARGET_LOCATION/$JAVA_NAME/bin/javaws
;;
Fedora | RedHatEnterpriseServer | CentOS )
fedora | rhel | centos )
alternatives --install /usr/bin/java java $JAVA_TARGET_LOCATION/$JAVA_NAME/bin/java 200000
alternatives --install /usr/bin/javaws javaws $JAVA_TARGET_LOCATION/$JAVA_NAME/bin/javaws 200000
alternatives --install /usr/bin/javac javac $JAVA_TARGET_LOCATION/$JAVA_NAME/bin/javac 200000

View File

@ -5,13 +5,13 @@ if [ "${DIB_DEBUG_TRACE:-0}" -gt 0 ]; then
fi
set -e
if [ $(lsb_release -is) = 'Fedora' ]; then
if [ "$DISTRO_NAME" = "fedora" ]; then
install-packages community-mysql community-mysql-libs community-mysql-server mysql-connector-java
mkdir -p /etc/mysql/conf.d
elif [ $(lsb_release -is) = 'RedHatEnterpriseServer' -o $(lsb_release -is) = 'CentOS' ]; then
elif [ "$DISTRO_NAME" = "rhel" -o "$DISTRO_NAME" = "centos" ]; then
install-packages mysql mysql-libs mysql-server mysql-connector-java
mkdir -p /etc/mysql/conf.d
elif [ $(lsb_release -is) = 'Ubuntu' ]; then
elif [ "$DISTRO_NAME" = "ubuntu" ]; then
install-packages mysql-server-5.5 mysql-client-5.5 libmysql-java
else
echo "Unknown distribution"

View File

@ -8,7 +8,7 @@ if [ "${DIB_DEBUG_TRACE:-0}" -gt 0 ]; then
set -x
fi
if [ $(lsb_release -is) = 'Ubuntu' ]; then
if [ "$DISTRO_NAME" = "ubuntu" ]; then
if [ -e "/etc/init/mysql.conf" ]; then
sed -i "s/start on runlevel \[.*\]/start on never runlevel [2345]/g" /etc/init/mysql.conf
sed -i '/bind-address/d' /etc/mysql/my.cnf

View File

@ -7,15 +7,13 @@ set -e
echo "Installing OpenJDK"
distro=$(lsb_release -is || :)
case "$distro" in
Ubuntu )
case "$DISTRO_NAME" in
ubuntu )
install-packages openjdk-7-jdk
JAVA_PATH=$(update-alternatives --list java)
JAVA_HOME=${JAVA_PATH%/bin/java}
;;
Fedora | RedHatEnterpriseServer | CentOS )
fedora | rhel | centos )
install-packages java-1.7.0-openjdk-devel
JAVA_HOME=$(rpm -E "%{java_home}")
;;

View File

@ -20,14 +20,12 @@ augtool -s set /files/etc/ssh/sshd_config/PermitTunnel yes
augtool -s set /files/etc/ssh/ssh_config/Host/StrictHostKeyChecking no
augtool -s set /files/etc/ssh/ssh_config/Host/GSSAPIAuthentication no
distro=$(lsb_release -is || :)
echo $distro
case "$distro" in
Ubuntu )
case "$DISTRO_NAME" in
ubuntu )
augtool -s set /files/etc/ssh/sshd_config/GSSAPICleanupCredentials yes
augtool -s set /files/etc/ssh/sshd_config/AuthorizedKeysFile %h/.ssh/authorized_keys
;;
Fedora )
fedora )
sed -i 's/ssh_pwauth: 0/ssh_pwauth: 1/' /etc/cloud/cloud.cfg
augtool -s clear /files/etc/sudoers/Defaults[type=':nrpe']/requiretty/negate
augtool -s set /files/etc/ssh/sshd_config/SyslogFacility AUTH
@ -35,14 +33,14 @@ case "$distro" in
augtool -s set /files/etc/ssh/sshd_config/RSAAuthentication yes
augtool -s set /files/etc/ssh/sshd_config/PubkeyAuthentication yes
;;
RedHatEnterpriseServer | CentOS )
rhel | centos )
sed -i 's/ssh_pwauth: 0/ssh_pwauth: 1/' /etc/cloud/cloud.cfg
augtool -s clear /files/etc/sudoers/Defaults[type=':nrpe']/requiretty/negate
augtool -s set /files/etc/ssh/sshd_config/SyslogFacility AUTH
augtool -s set /files/etc/ssh/sshd_config/PubkeyAuthentication yes
;;
* )
echo "Unknown distro: $distro, exiting"
echo "Unknown distro: $DISTRO_NAME, exiting"
exit 1
;;
esac