Skip to content

Commit

Permalink
Fix Installation (#303)
Browse files Browse the repository at this point in the history
* Fixes `gen settings` command on Windows install script
* Fixes `DOSKEY tstart` command in Windows install script
* Fixes issue with `CONDA_HOME` in Linux install script when installing Docker
* Temporary fix to resolve branch in the docs on Read The Docs
* bumps version to 2.0.1
  • Loading branch information
sdc50 authored Jun 23, 2017
1 parent cba2666 commit 6d99acd
Show file tree
Hide file tree
Showing 5 changed files with 118 additions and 102 deletions.
8 changes: 7 additions & 1 deletion docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,13 @@
# file that is read. This is the right place to add substitutions that should be
# available in every file.
branch = pbr.git._run_git_command(['rev-parse', '--abbrev-ref', 'HEAD'], pbr.git._get_git_directory())
branch = 'dev' if branch == 'HEAD' else branch
on_rtd = os.environ.get('READTHEDOCS') == 'True'
if on_rtd:
# Hack to try to get the branch name if possible, otherwise assume 'release'
branch = pbr.git._run_git_command(['branch'], pbr.git._get_git_directory()).split('*')[-1].split('\n')[0].strip(')').split('/')
branch = branch[-1] if len(branch) == 2 else 'release'
print(branch)

rst_epilog = """
.. |branch| replace:: {branch}
""".format(branch=branch)
Expand Down
2 changes: 1 addition & 1 deletion environment_py2.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ dependencies:
- sqlalchemy=1.1*
- requests=2.18*
- selenium=3.4*
- coverage=4.4*
- coverage=4*
- docker-py<1.10
- geoalchemy2=0.4*
- owslib=0.14*
Expand Down
4 changes: 2 additions & 2 deletions scripts/install_tethys.bat
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,7 @@ IF NOT "!ALLOWED_HOST!"=="127.0.0.1" (
SET ALLOWED_HOST_OPT=--allowed-host !ALLOWED_HOST!
)

tethys gen settings -d "!TETHYS_HOME!\src\tethys_apps" !ALLOWED_HOST_OPT! --db-username !TETHYS_DB_USERNAME! --db-password !TETHYS_DB_PASSWORD! --db-port !TETHYS_DB_PORT!
tethys gen settings !ALLOWED_HOST_OPT! --db-username !TETHYS_DB_USERNAME! --db-password !TETHYS_DB_PASSWORD! --db-port !TETHYS_DB_PORT!

IF %ERRORLEVEL% NEQ 0 (
ECHO Error occured while setting up the !CONDA_ENV_NAME! environment.
Expand Down Expand Up @@ -309,7 +309,7 @@ ECHO DOSKEY tstartdb=pg_ctl -U postgres -D "%%TETHYS_HOME%%\psql\data" -l "%%TET
ECHO DOSKEY tethys_stop_db=pg_ctl -U postgres -D "%%TETHYS_HOME%%\psql\data" stop >>"!ACTIVATE_SCRIPT!"
ECHO DOSKEY tstopdb=pg_ctl -U postgres -D "%%TETHYS_HOME%%\psql\data" stop >> "!ACTIVATE_SCRIPT!"
ECHO DOSKEY tms=tethys manage start -p !ALLOWED_HOST!:%%TETHYS_PORT%% >> "!ACTIVATE_SCRIPT!"
ECHO DOSKEY tstart=tstartdb & tms >> "!ACTIVATE_SCRIPT!"
ECHO DOSKEY tstart=pg_ctl -U postgres -D "%%TETHYS_HOME%%\psql\data" -l "%%TETHYS_HOME%%\psql\logfile" start -o "-p %%TETHYS_DB_PORT%%" $T tethys manage start -p !ALLOWED_HOST!:%%TETHYS_PORT%% >> "!ACTIVATE_SCRIPT!"

ECHO @ECHO OFF>> "!DEACTIVATE_SCRIPT!"
ECHO SET TETHYS_HOME=>> "!DEACTIVATE_SCRIPT!"
Expand Down
204 changes: 107 additions & 97 deletions scripts/install_tethys.sh
Original file line number Diff line number Diff line change
Expand Up @@ -298,109 +298,16 @@ then

echo "# Tethys Platform" >> ~/${BASH_PROFILE}
echo "alias t='. ${CONDA_HOME}/bin/activate ${CONDA_ENV_NAME}'" >> ~/${BASH_PROFILE}

echo "Tethys installation complete!"
echo
echo "NOTE: to enable the new alias 't' which activates the tethys environment you must run '. ~/${BASH_PROFILE}'"

fi

# Install Docker (if flag is set)
set +e # don't exit on error anymore

installation_warning(){
echo "WARNING: installing docker on $1 is not officially supported by the Tethys install script. Attempting to install with $2 script."
}

finalize_docker_install(){
sudo groupadd docker
sudo gpasswd -a ${USER} docker
. ${CONDA_HOME}/bin/activate ${CONDA_ENV_NAME}
sg docker -c "tethys docker init ${DOCKER_OPTIONS}"
. deactivate
echo "Docker installation finished!"
echo "You must re-login for Docker permissions to be activated."
echo "(Alternatively you can run 'newgrp docker')"
}

ubuntu_debian_docker_install(){
if [ "${LINUX_DISTRIBUTION}" != "ubuntu" ] && [ ${LINUX_DISTRIBUTION} != "debian" ]
then
installation_warning ${LINUX_DISTRIBUTION} "Ubuntu"
fi

sudo apt-get update
sudo apt-get install -y apt-transport-https ca-certificates curl gnupg2 software-properties-common
curl -fsSL https://download.docker.com/linux/${LINUX_DISTRIBUTION}/gpg | sudo apt-key add -
sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/${LINUX_DISTRIBUTION} $(lsb_release -cs) stable"
sudo apt-get update
sudo apt-get install -y docker-ce

finalize_docker_install
}

centos_docker_install(){
if [ "${LINUX_DISTRIBUTION}" != "centos" ]
then
installation_warning ${LINUX_DISTRIBUTION} "CentOS"
fi

sudo yum -y install yum-utils
sudo yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo
sudo yum makecache fast
sudo yum -y install docker-ce
sudo systemctl start docker
sudo systemctl enable docker

finalize_docker_install
}

fedora_docker_install(){
if [ "${LINUX_DISTRIBUTION}" != "fedora" ]
then
installation_warning ${LINUX_DISTRIBUTION} "Fedora"
fi

sudo dnf -y install -y dnf-plugins-core
sudo dnf config-manager --add-repo https://download.docker.com/linux/fedora/docker-ce.repo
sudo dnf makecache fast
sudo dnf -y install docker-ce
sudo systemctl start docker
sudo systemctl enable docker

finalize_docker_install
}

if [ -n "${LINUX_DISTRIBUTION}" -a "${INSTALL_DOCKER}" = "true" ]
then
# prompt for sudo
echo "Docker installation requires some commands to be run with sudo. Please enter password:"
sudo echo "Installing Docker..."

case ${LINUX_DISTRIBUTION} in
debian)
ubuntu_debian_docker_install
;;
ubuntu)
ubuntu_debian_docker_install
;;
centos)
centos_docker_install
;;
redhat)
centos_docker_install
;;
fedora)
fedora_docker_install
;;
*)
echo "Automated Docker installation on ${LINUX_DISTRIBUTION} is not supported. Please see https://docs.docker.com/engine/installation/ for more information on installing Docker."
;;
esac
fi


# Rename some variables for reference after deactivating tethys environment.
TETHYS_CONDA_HOME=${CONDA_HOME}
TETHYS_CONDA_ENV_NAME=${CONDA_ENV_NAME}

# Install Production configuration if flag is set

ubuntu_debian_production_install() {
sudo apt update
Expand Down Expand Up @@ -476,6 +383,7 @@ then
;;
esac


. ${CONDA_HOME}/bin/activate ${CONDA_ENV_NAME}
pg_ctl -U postgres -D "${TETHYS_HOME}/psql/data" -l "${TETHYS_HOME}/psql/logfile" start -o "-p ${TETHYS_DB_PORT}"
echo "Waiting for databases to startup..."; sleep 5
Expand Down Expand Up @@ -526,6 +434,108 @@ then
echo "unalias trs" >> "${DEACTIVATE_SCRIPT}"
fi


# Install Docker (if flag is set

installation_warning(){
echo "WARNING: installing docker on $1 is not officially supported by the Tethys install script. Attempting to install with $2 script."
}

finalize_docker_install(){
sudo groupadd docker
sudo gpasswd -a ${USER} docker
. ${TETHYS_CONDA_HOME}/bin/activate ${TETHYS_CONDA_ENV_NAME}
sg docker -c "tethys docker init ${DOCKER_OPTIONS}"
. deactivate
echo "Docker installation finished!"
echo "You must re-login for Docker permissions to be activated."
echo "(Alternatively you can run 'newgrp docker')"
}

ubuntu_debian_docker_install(){
if [ "${LINUX_DISTRIBUTION}" != "ubuntu" ] && [ ${LINUX_DISTRIBUTION} != "debian" ]
then
installation_warning ${LINUX_DISTRIBUTION} "Ubuntu"
fi

sudo apt-get update
sudo apt-get install -y apt-transport-https ca-certificates curl gnupg2 software-properties-common
curl -fsSL https://download.docker.com/linux/${LINUX_DISTRIBUTION}/gpg | sudo apt-key add -
sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/${LINUX_DISTRIBUTION} $(lsb_release -cs) stable"
sudo apt-get update
sudo apt-get install -y docker-ce

finalize_docker_install
}

centos_docker_install(){
if [ "${LINUX_DISTRIBUTION}" != "centos" ]
then
installation_warning ${LINUX_DISTRIBUTION} "CentOS"
fi

sudo yum -y install yum-utils
sudo yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo
sudo yum makecache fast
sudo yum -y install docker-ce
sudo systemctl start docker
sudo systemctl enable docker

finalize_docker_install
}

fedora_docker_install(){
if [ "${LINUX_DISTRIBUTION}" != "fedora" ]
then
installation_warning ${LINUX_DISTRIBUTION} "Fedora"
fi

sudo dnf -y install -y dnf-plugins-core
sudo dnf config-manager --add-repo https://download.docker.com/linux/fedora/docker-ce.repo
sudo dnf makecache fast
sudo dnf -y install docker-ce
sudo systemctl start docker
sudo systemctl enable docker

finalize_docker_install
}

if [ -n "${LINUX_DISTRIBUTION}" -a "${INSTALL_DOCKER}" = "true" ]
then
# prompt for sudo
echo "Docker installation requires some commands to be run with sudo. Please enter password:"
sudo echo "Installing Docker..."

case ${LINUX_DISTRIBUTION} in
debian)
ubuntu_debian_docker_install
;;
ubuntu)
ubuntu_debian_docker_install
;;
centos)
centos_docker_install
;;
redhat)
centos_docker_install
;;
fedora)
fedora_docker_install
;;
*)
echo "Automated Docker installation on ${LINUX_DISTRIBUTION} is not supported. Please see https://docs.docker.com/engine/installation/ for more information on installing Docker."
;;
esac
fi


if [ -z "${SKIP_TETHYS_INSTALL}" ]
then
echo "Tethys installation complete!"
echo
echo "NOTE: to enable the new alias 't' which activates the tethys environment you must run '. ~/${BASH_PROFILE}'"
fi

on_exit(){
set +e
set +x
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

requires = []

version = '2.0.0'
version = '2.0.1'

setup(
name='tethys_platform',
Expand Down

0 comments on commit 6d99acd

Please sign in to comment.