Add cloudshell installation support

This commit is contained in:
Fred Park 2017-06-27 10:12:56 -07:00
Родитель 54422ce2eb
Коммит 5830209041
2 изменённых файлов: 85 добавлений и 64 удалений

Просмотреть файл

@ -5,6 +5,7 @@
### Added
- Version metadata added to pools and jobs with warnings generated for
mismatches (#89)
- Cloud shell installation support
### Changed
- Update Docker images to Alpine 3.6 (#65)

Просмотреть файл

@ -6,15 +6,17 @@ set -o pipefail
# vars
PYTHON=python
PIP=pip
SUDO=sudo
VENV_NAME=
# process options
while getopts "h?3e:" opt; do
while getopts "h?3ce:" opt; do
case "$opt" in
h|\?)
echo "install.sh parameters"
echo ""
echo "-3 install for Python 3.3+"
echo "-c install for Cloud Shell"
echo "-e [environment name] install to a virtual environment"
echo ""
exit 1
@ -23,6 +25,12 @@ while getopts "h?3e:" opt; do
PYTHON=python3
PIP=pip3
;;
c)
PYTHON=python3
PIP=pip3
VENV_NAME=cloudshell
SUDO=
;;
e)
VENV_NAME=$OPTARG
;;
@ -31,19 +39,21 @@ done
shift $((OPTIND-1))
[ "$1" = "--" ] && shift
# check to ensure this is not being run directly as root
if [ $(id -u) -eq 0 ]; then
# non-cloud shell environment checks
if [ ! -z $SUDO ]; then
# check to ensure this is not being run directly as root
if [ $(id -u) -eq 0 ]; then
echo "Installation cannot be performed as root or via sudo."
echo "Please install as a regular user."
exit 1
fi
# check for sudo
if hash sudo 2> /dev/null; then
fi
# check for sudo
if hash sudo 2> /dev/null; then
echo "sudo found."
else
else
echo "sudo not found. Please install sudo first before proceeding."
exit 1
fi
fi
# check that shipyard.py is in cwd
@ -123,8 +133,9 @@ DISTRIB_ID=${DISTRIB_ID,,}
DISTRIB_RELEASE=${DISTRIB_RELEASE,,}
# install requisite packages from distro repo
if [ $DISTRIB_ID == "ubuntu" ] || [ $DISTRIB_ID == "debian" ]; then
sudo apt-get update
if [ ! -z $SUDO ] || [ $(id -u) -eq 0 ]; then
if [ $DISTRIB_ID == "ubuntu" ] || [ $DISTRIB_ID == "debian" ]; then
$SUDO apt-get update
if [ $PYTHON == "python" ]; then
PYTHON_PKGS="libpython-dev python-dev"
if [ $ANACONDA -eq 0 ]; then
@ -136,10 +147,10 @@ if [ $DISTRIB_ID == "ubuntu" ] || [ $DISTRIB_ID == "debian" ]; then
PYTHON_PKGS="$PYTHON_PKGS python3-pip"
fi
fi
sudo apt-get install -y --no-install-recommends \
$SUDO apt-get install -y --no-install-recommends \
build-essential libssl-dev libffi-dev openssl \
openssh-client rsync $PYTHON_PKGS
elif [ $DISTRIB_ID == "centos" ] || [ $DISTRIB_ID == "rhel" ]; then
elif [ $DISTRIB_ID == "centos" ] || [ $DISTRIB_ID == "rhel" ]; then
if [ $PYTHON == "python" ]; then
PYTHON_PKGS="python-devel"
else
@ -155,38 +166,47 @@ elif [ $DISTRIB_ID == "centos" ] || [ $DISTRIB_ID == "rhel" ]; then
fi
PYTHON_PKGS="python34-devel"
fi
sudo yum install -y gcc openssl-devel libffi-devel openssl \
$SUDO yum install -y gcc openssl-devel libffi-devel openssl \
openssh-clients rsync $PYTHON_PKGS
if [ $ANACONDA -eq 0 ]; then
curl -fSsL https://bootstrap.pypa.io/get-pip.py | sudo $PYTHON
curl -fSsL https://bootstrap.pypa.io/get-pip.py | $SUDO $PYTHON
fi
elif [ $DISTRIB_ID == "opensuse" ] || [ $DISTRIB_ID == "sles" ]; then
sudo zypper ref
elif [ $DISTRIB_ID == "opensuse" ] || [ $DISTRIB_ID == "sles" ]; then
$SUDO zypper ref
if [ $PYTHON == "python" ]; then
PYTHON_PKGS="python-devel"
else
PYTHON_PKGS="python3-devel"
fi
sudo zypper -n in gcc libopenssl-devel libffi48-devel openssl \
$SUDO zypper -n in gcc libopenssl-devel libffi48-devel openssl \
openssh rsync $PYTHON_PKGS
if [ $ANACONDA -eq 0 ]; then
curl -fSsL https://bootstrap.pypa.io/get-pip.py | sudo $PYTHON
curl -fSsL https://bootstrap.pypa.io/get-pip.py | $SUDO $PYTHON
fi
else
else
echo "Unsupported distribution."
echo "Please refer to the Installation documentation for manual installation steps."
exit 1
fi
fi
# create virtual env if required and install required python packages
if [ ! -z $VENV_NAME ]; then
# install virtual env if required
if [ $INSTALL_VENV_BIN -eq 1 ]; then
sudo $PIP install virtualenv
if [ ! -z $SUDO ] || [ $(id -u) -eq 0 ]; then
$SUDO $PIP install virtualenv
else
$PIP install --user virtualenv
fi
fi
if [ $ANACONDA -eq 0 ]; then
# create venv if it doesn't exist
if [ ! -z $SUDO ] || [ $(id -u) -eq 0 ]; then
virtualenv -p $PYTHON $VENV_NAME
else
$HOME/.local/bin/virtualenv -p $PYTHON $VENV_NAME
fi
source $VENV_NAME/bin/activate
$PIP install --upgrade pip setuptools
$PIP install --upgrade -r requirements.txt
@ -207,7 +227,7 @@ if [ ! -z $VENV_NAME ]; then
source deactivate $VENV_NAME
fi
else
sudo $PIP install --upgrade pip setuptools
$SUDO $PIP install --upgrade pip setuptools
$PIP install --upgrade --user -r requirements.txt
fi