bigchaindb/pkg/scripts/bootstrap_helper.sh
Muawia Khan 10e55aa4e7
Problem: No automated way to set up a dev/test network (#2300)
* Problem: No automated way to set up a dev/test network

* Problem: docs not updated for stack, ansible and docker based dev environments

* Problem: Using apt triggers java runtime installation on MacOS

- Update pre_tasks in ansible
- Update bigchaindb-stop playbook to handle pre_tasks

* Update Tendermint version to 0.19.3 from 0.19.2

* Update tendermint version to 0.19.3 everywhere else

* Problem: Sphinx warns about duplicate section labels

Solution: Don't use sphinx.ext.autosectionlabel

* Problem: Sphinx complains that run-node-with-docker not in any TOC

Solution: Add run-node-with-docker to a TOC (i.e. to an index.rst file)

* Tendermint has not tagged `0.19.3` container

* Problem: Internal hyperlinks to new pages not working

Solution: Add .html to the ends of the filename strings

* Problem: Invalid script imports

* Problem: Invalid comparison for supported OS version

* Addressing comments I

* Problem: No way to configure dev/forked repo for developers

* Problem: Docs not updated with STACK_REPO parameter

* Addressing comments II
2018-05-31 16:56:45 +02:00

132 lines
3.7 KiB
Bash
Executable File

#!/usr/bin/env bash
BASEDIR="${BASH_SOURCE%/*}"
if [[ ! -d "$BASEDIR" ]]; then BASEDIR="$PWD"; fi
. "$BASEDIR/bootstrap_constants.sh"
validate_os_version_and_deps(){
if $1; then
case $2 in
centos)
if [[ ($(version_compare_gt $3 $MINIMUM_CENTOS_VERSION) == 0)
|| ($(version_compare_eq $3 $MINIMUM_CENTOS_VERSION) == 0) ]]; then
rpm -q "${OS_DEPENDENCIES[@]}" > /dev/null 2>&1
echo $?
else
echo 2
fi
;;
debian)
if [[ ($(version_compare_gt $3 $MINIMUM_DEBIAN_VERSION) == 0)
|| ($(version_compare_eq $3 $MINIMUM_DEBIAN_VERSION) == 0) ]]; then
dpkg -s "${OS_DEPENDENCIES[@]}" > /dev/null 2>&1
echo $?
else
echo 2
fi
;;
fedora)
if [[ ($(version_compare_gt $3 $MINIMUM_FEDORA_VERSION) == 0)
|| ($(version_compare_eq $3 $MINIMUM_FEDORA_VERSION) == 0) ]]; then
rpm -q "${OS_DEPENDENCIES[@]}" > /dev/null 2>&1
echo $?
else
echo 2
fi
;;
ubuntu)
if [[ ($(version_compare_gt $3 $MINIMUM_UBUNTU_VERSION) == 0)
|| ($(version_compare_eq $3 $MINIMUM_UBUNTU_VERSION) == 0) ]]; then
dpkg -s "${OS_DEPENDENCIES[@]}" > /dev/null 2>&1
echo $?
else
echo 2
fi
;;
macOS)
pip show "${OS_DEPENDENCIES[@]}" > /dev/null 2>&1
echo $?
;;
*)
echo "Supported OS(s) are: [ ${SUPPORTED_OS[*]} ]."
exit 1
;;
esac
else
echo "Supported OS(s) are: [ ${SUPPORTED_OS[*]} ]."
fi
}
version_compare_gt(){
test "$(printf '%s\n' "$@" | sort -V | head -n 1)" != "$1"
echo $?
}
version_compare_eq(){
test "$(printf '%s\n' "$@" | sort -V | head -n 1)" == "$2"
echo $?
}
install_ansible() {
echo "Installing Ansible..."
case $1 in
centos)
yum install epel-release -y
yum install -y https://centos7.iuscommunity.org/ius-release.rpm
yum install ansible -y
;;
debian)
apt-get update -y && apt-get install --fix-missing
apt-get install lsb-release software-properties-common gnupg -y
echo "deb http://ppa.launchpad.net/ansible/ansible/ubuntu trusty main" | tee -a /etc/apt/sources.list.d/ansible-debian.list
apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 93C4A3FD7BB9C367
apt-get update
apt-get install -y ansible
echo 'localhost' > /etc/ansible/hosts
;;
fedora)
export LC_ALL=C
dnf makecache
dnf -y install ansible
;;
macOS)
easy_install pip
pip install ansible
;;
ubuntu)
apt-get update -y
apt-get install -y software-properties-common
apt-add-repository ppa:ansible/ansible -y
apt-get update -y
apt-get install -y ansible
;;
*)
echo "Supported OS(s) are: [ ${SUPPORTED_OS[*]} ]."
esac
}
uninstall_ansible() {
echo "Uninstalling Ansible..."
case $1 in
centos)
yum remove ansible -y
;;
debian)
apt-get purge ansible -y
;;
fedora)
export LC_ALL=C
dnf remove ansible -y
;;
macOS)
pip uninstall ansible -y
;;
ubuntu)
apt-get purge ansible -y
;;
*)
echo "Supported OS(s) are: [ ${SUPPORTED_OS[*]} ]."
esac
}