Commit 756be74c by Zachary Robbins

Script can now handle installing fullstack and devstack.

parent 68c34ad7
......@@ -9,18 +9,33 @@ function usage
--- install_devstack.sh ---
Usage: $ bash install_devstack.sh release [-p] [-v vagrant_mount_base] [-h]
Usage: $ bash install_devstack.sh stack release [-p] [-b vagrant_mount_base] [-l log_level] [-h]
Installs the Open edX developer stack. More information on installing devstack
can be found here: https://openedx.atlassian.net/wiki/display/OpenOPS/Running+Devstack
can be found here: https://openedx.atlassian.net/wiki/display/OpenOPS/Running+Devstack.
Reach out on the Open edX community Slack on #ops (https://open.edx.org/blog/open-edx-slack)
or the Open edX Ops Google Group (https://groups.google.com/forum/#!forum/openedx-ops) to
get support questions answered.
This script captures a log of all output produced during runtime, and saves it in a .log
file within the current directory. If you encounter an error during installation, this is
an invaluable tool for edX developers to help discover what went wrong, so please share it
if you reach out for support!
NOTE: This script assumes you have never installed devstack before. Installing multiple
versions of devstack can often cause conflicts that this script is not prepared to handle.
Reach out on the edX community Slack if you need more help in this topic.
versions of devstack can often cause conflicts that this script is not prepared to handle.
stack
Either 'fullstack' or 'devstack' (no quotes). Full stack mimics a production
environment, whereas devstack is useful if you plan on modifying the Open edX
code. You must specify this. If you choose fullstack, 'release' should be the
latest named-release. If you choose devstack, 'release' should be the latest
named-release or master.
release
The release of Open edX you wish to run. Upgrade to the given git ref 'release'.
You must specify this. Named released are called "named-release/dogwood",
The release of Open edX you wish to run. Install the given git ref 'release'.
You must specify this. Named releases are called "named-release/dogwood",
"named-release/dogwood.2", and so on. We recommend the latest stable named
release for general members of the open source community. Named releases can
be found at: https://openedx.atlassian.net/wiki/display/DOC/Open+edX+Releases.
......@@ -29,10 +44,13 @@ function usage
-p
Enable use of "preview" from within Studio.
-v vagrant_mount_base
-b vagrant_mount_base
Customize the location of the source code that gets cloned during the
devstack provisioning.
-l log_level
Log verbosity. 0 = no logging, 1 = full logs (default)
-h
Show this help and exit.
......@@ -40,12 +58,12 @@ function usage
EOM
}
# Allow for installation of fullstack, describe differences
#Remove directory for logs, allow for turning off logging, talk about logging in usage
# See if I can change verbosity of ansible-playbook commands in Vagrantfile using $EXTRA_VARS
# Logging
mkdir -p install_logs
exec > >(tee install_logs/install-$(date +%Y%m%d-%H%M%S).log) 2>&1
echo "Logs located in install_logs directory"
log_level=1
# OPENEDX_RELEASE
release=""
# Enable preview in Studio
......@@ -53,22 +71,27 @@ enable_preview=0
# Vagrant source code provision location
vagrant_mount_location=""
if [[ $# -lt 1 || ${1:0:1} == '-' ]]; then
if [[ $# -lt 2 || ${1:0:1} == '-' || ${2:0:1} == '-' ]]; then
usage
exit 1
fi
stack=$1
shift
release=$1
shift
while getopts "r:pv:h" opt; do
while getopts "r:pb:l:h" opt; do
case "$opt" in
p)
enable_preview=1
;;
v)
b)
vagrant_mount_location=$OPTARG
;;
l)
log_level=$OPTARG
;;
*)
usage
exit 1
......@@ -76,12 +99,19 @@ while getopts "r:pv:h" opt; do
esac
done
if [[ $log_level == 1 ]]; then
exec > >(tee install-$(date +%Y%m%d-%H%M%S).log) 2>&1
echo "Logging enabled."
else
echo "Logging disabled."
fi
ERROR='\033[0;31m' # Red
WARN='\033[1;33m' # Yellow
SUCCESS='\033[0;32m' # Green
NC='\033[0m' # No Color
if [[ $release != "master" ]]; then
echo -e "${WARN}The release you entered is not 'master'. Please be aware that a branch other than master or a release other than the latest named-release could cause errors.${NC}"
fi
export OPENEDX_RELEASE=$release
# Check if mount location was changed
if [[ $vagrant_mount_location != "" ]]; then
......@@ -89,21 +119,42 @@ if [[ $vagrant_mount_location != "" ]]; then
export VAGRANT_MOUNT_BASE=vagrant_mount_location
fi
export OPENEDX_RELEASE=$release
mkdir -p devstack
cd devstack
if [[ $stack == "devstack" ]]; then # Install devstack
# Warn if release chosen is not master or named-releaser
if [[ $release != "master" && $release != *"named-release"* ]]; then
echo -e "${WARN}The release you entered is not 'master' or a named-release. Please be aware that a branch other than master or a release other than the latest named-release could cause errors when installing devstack.${NC}"
fi
wiki_link="https://openedx.atlassian.net/wiki/display/OpenOPS/Running+Devstack"
mkdir -p devstack
cd devstack
curl -L https://raw.githubusercontent.com/edx/configuration/${OPENEDX_RELEASE}/vagrant/release/devstack/Vagrantfile > Vagrantfile
vagrant plugin install vagrant-vbguest
elif [[ $stack == "fullstack" ]]; then # Install fullstack
# Warn if release chosen is not named-release
if [[ $release != *"named-release"* ]]; then
echo -e "${WARN}The release you entered is not a named-release. Please be aware that a branch other than the latest named-release could cause errors when installing fullstack.${NC}"
fi
wiki_link="https://openedx.atlassian.net/wiki/display/OpenOPS/Running+Fullstack"
mkdir -p fullstack
cd fullstack
curl -L https://raw.githubusercontent.com/edx/configuration/${OPENEDX_RELEASE}/vagrant/release/fullstack/Vagrantfile > Vagrantfile
vagrant plugin install vagrant-hostsupdater
else # Throw error
echo -e "${ERROR}Unrecognized stack name, must be either devstack or fullstack!${NC}"
exit 1
fi
# Install devstack
curl -L https://raw.githubusercontent.com/edx/configuration/${OPENEDX_RELEASE}/vagrant/release/devstack/Vagrantfile > Vagrantfile
vagrant plugin install vagrant-vbguest
vagrant up --provider virtualbox
# Check if preview mode was chosen
if [[ $enable_preview -eq 1 ]]; then
if [[ $enable_preview != 1 ]] || grep -q '192.168.33.10 preview.localhost' /etc/hosts; then
echo "Studio preview already enabled, skipping..."
else
echo "Enabling use of preview within Studio..."
sudo bash -c "echo '192.168.33.10 preview.localhost' >> /etc/hosts"
sudo bash -c "echo '192.168.33.10 preview.localhost' >> /etc/hosts"
fi
echo "Finished installing! You may now login using 'vagrant ssh'"
echo "Refer to the edX wiki for more information on using devstack."
echo -e "${SUCCESS}Finished installing! You may now login using 'vagrant ssh'"
echo -e "Refer to the edX wiki ("$wiki_link") for more information on using "$stack".${NC}"
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment