97 lines
2.6 KiB
Bash
Executable File
97 lines
2.6 KiB
Bash
Executable File
#!/bin/bash
|
|
|
|
set -ex
|
|
|
|
distro=$(awk -F= '/^ID=/ {gsub(/\"/, "", $2); print $2}' /etc/*release)
|
|
export distro=${DISTRO:=$distro}
|
|
|
|
case ${distro} in
|
|
debian|ubuntu)
|
|
apt-get update
|
|
apt-get upgrade -y
|
|
apt-get install -y --no-install-recommends \
|
|
git \
|
|
ca-certificates \
|
|
netbase \
|
|
python \
|
|
virtualenv \
|
|
lsb-release \
|
|
sudo
|
|
;;
|
|
centos)
|
|
yum upgrade -y
|
|
yum install -y --setopt=skip_missing_names_on_install=False \
|
|
git \
|
|
python-virtualenv \
|
|
redhat-lsb-core \
|
|
sudo
|
|
;;
|
|
*)
|
|
echo "Unknown distro: ${distro}"
|
|
exit 1
|
|
;;
|
|
esac
|
|
|
|
if [[ "${PROJECT}" == 'requirements' ]]; then
|
|
/opt/loci/scripts/requirements.sh
|
|
exit 0
|
|
fi
|
|
|
|
mkdir -p /opt/loci/
|
|
cp $(dirname $0)/{clone_project.sh,pip_install.sh,fetch_wheels.py} /opt/loci/
|
|
|
|
# NOTE(SamYaple): --system-site-packages flag allows python to use libraries
|
|
# outside of the virtualenv if they do not exist inside the venv. This is a
|
|
# requirement for using python-rbd which is not pip installable and is only
|
|
# available in packaged form.
|
|
virtualenv --system-site-packages /var/lib/openstack/
|
|
source /var/lib/openstack/bin/activate
|
|
pip install -U pip
|
|
pip install -U setuptools wheel
|
|
|
|
$(dirname $0)/clone_project.sh
|
|
|
|
$(dirname $0)/pip_install.sh \
|
|
/tmp/${PROJECT} \
|
|
pycrypto \
|
|
pymysql \
|
|
python-memcached \
|
|
uwsgi \
|
|
bindep
|
|
|
|
PACKAGES=($(bindep -f /opt/loci/bindep.txt -b ${PROJECT} ${PROFILES} || :))
|
|
|
|
groupadd -g 42424 ${PROJECT}
|
|
useradd -u 42424 -g ${PROJECT} -M -d /var/lib/${PROJECT} -s /usr/sbin/nologin -c "${PROJECT} user" ${PROJECT}
|
|
|
|
mkdir -p /etc/${PROJECT} /var/log/${PROJECT} /var/lib/${PROJECT} /var/cache/${PROJECT}
|
|
chown ${PROJECT}:${PROJECT} /etc/${PROJECT} /var/log/${PROJECT} /var/lib/${PROJECT} /var/cache/${PROJECT}
|
|
|
|
case ${distro} in
|
|
debian|ubuntu)
|
|
if [[ ! -z ${PACKAGES} ]]; then
|
|
apt-get install -y --no-install-recommends ${PACKAGES[@]}
|
|
fi
|
|
apt-get purge -y --auto-remove \
|
|
git \
|
|
virtualenv
|
|
rm -rf /var/lib/apt/lists/*
|
|
;;
|
|
centos)
|
|
if [[ ! -z ${PACKAGES} ]]; then
|
|
yum -y --setopt=skip_missing_names_on_install=False install ${PACKAGES[@]}
|
|
fi
|
|
yum -y autoremove \
|
|
git \
|
|
python-virtualenv
|
|
yum clean all
|
|
;;
|
|
*)
|
|
echo "Unknown distro: ${distro}"
|
|
exit 1
|
|
;;
|
|
esac
|
|
|
|
rm -rf /tmp/* /root/.cache
|
|
find /usr/ /var/ -type f -name "*.pyc" -delete
|