Commit d49a8b19 by Zachary Robbins

Made recommended improvements to script.

parent e554ad10
...@@ -9,11 +9,11 @@ function usage ...@@ -9,11 +9,11 @@ function usage
--- install_stack.sh --- --- install_stack.sh ---
Usage: $ bash install_stack.sh stack release [-p] [-b vagrant_mount_base] [-l] [-v] [-h] Usage: $ bash install_stack.sh stack release [-b vagrant_mount_base] [-v] [-h]
Installs the Open edX devstack or fullstack. Reach out on the Open edX community Slack Installs the Open edX devstack or fullstack. If you encounter any trouble or have
on #ops (https://open.edx.org/blog/open-edx-slack) or the Open edX Ops Google Group questions regarding installation of devstack/fullstack, head over to
(https://groups.google.com/forum/#!forum/openedx-ops) to get support questions answered. https://open.edx.org/getting-help.
This script captures a log of all output produced during runtime, and saves it in a .log 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 file within the current directory. If you encounter an error during installation, this is
...@@ -28,26 +28,21 @@ function usage ...@@ -28,26 +28,21 @@ function usage
Either 'fullstack' or 'devstack' (no quotes). Full stack mimics a production Either 'fullstack' or 'devstack' (no quotes). Full stack mimics a production
environment, whereas devstack is useful if you plan on modifying the Open edX 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 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 latest open-release. If you choose devstack, 'release' should be the latest
named-release or master. open-release or master.
release release
The release of Open edX you wish to run. Install the given git ref 'release'. 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", You must specify this. Named releases are called "open-release/eucalyptus",
"named-release/dogwood.2", and so on. We recommend the latest stable named "open-release/eucalyptus.2", and so on. We recommend the latest stable open
release for general members of the open source community. Named releases can 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. be found at: https://openedx.atlassian.net/wiki/display/DOC/Open+edX+Releases.
If you plan on modifying the code, we recommend the "master" branch. If you plan on modifying the code, we recommend the "master" branch.
-p
Enable use of "preview" from within Studio.
-b vagrant_mount_base -b vagrant_mount_base
Customize the location of the source code that gets cloned during the Customize the location of the source code that gets cloned during the
devstack provisioning. devstack provisioning. The default is the current directory. This option is
not valid if installing fullstack.
-l
Disable logging. Enabled by default.
-v -v
Verbose output from ansible playbooks. Verbose output from ansible playbooks.
...@@ -60,14 +55,16 @@ function usage ...@@ -60,14 +55,16 @@ function usage
EOM EOM
} }
# Logging
logging=1 ERROR='\033[0;31m' # Red
WARN='\033[1;33m' # Yellow
SUCCESS='\033[0;32m' # Green
NC='\033[0m' # No Color
# Output verbosity # Output verbosity
verbosity=0 verbosity=0
# OPENEDX_RELEASE # OPENEDX_RELEASE
release="" release=""
# Enable preview in Studio
enable_preview=0
# Vagrant source code provision location # Vagrant source code provision location
vagrant_mount_location="" vagrant_mount_location=""
...@@ -81,16 +78,15 @@ shift ...@@ -81,16 +78,15 @@ shift
release=$1 release=$1
shift shift
while getopts "pb:lvh" opt; do while getopts "b:vh" opt; do
case "$opt" in case "$opt" in
p)
enable_preview=1
;;
b) b)
vagrant_mount_location=$OPTARG if [[ $stack == "devstack" ]]; then
;; vagrant_mount_location=$OPTARG
l) else
logging=0 echo -e "${ERROR}Cannot change mount location if installing fullstack!${NC}"
exit 1
fi
;; ;;
v) v)
verbosity=1 verbosity=1
...@@ -106,45 +102,41 @@ while getopts "pb:lvh" opt; do ...@@ -106,45 +102,41 @@ while getopts "pb:lvh" opt; do
esac esac
done done
if [[ $logging > 0 ]]; then exec > >(tee install-$(date +%Y%m%d-%H%M%S).log) 2>&1
exec > >(tee install-$(date +%Y%m%d-%H%M%S).log) 2>&1 echo "Capturing output to install-$(date +%Y%m%d-%H%M%S).log."
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
export OPENEDX_RELEASE=$release export OPENEDX_RELEASE=$release
# Check if mount location was changed # Check if mount location was changed
if [[ $vagrant_mount_location != "" ]]; then if [[ $vagrant_mount_location != "" ]]; then
echo "Changing Vagrant provision location to "$vagrant_mount_location"..." echo "Changing Vagrant provision location to $vagrant_mount_location..."
export VAGRANT_MOUNT_BASE=vagrant_mount_location export VAGRANT_MOUNT_BASE=vagrant_mount_location
fi fi
if [[ -d "$stack" ]]; then
echo -e "${ERROR}A $stack directory already exists here. If you already tried installing $stack, make sure to vagrant destroy the $stack machine and rm -rf the $stack directory before trying to reinstall. If you would like to install a separate $stack, change to a different directory and try running the script again.${NC}"
exit 1
fi
if [[ $stack == "devstack" ]]; then # Install devstack if [[ $stack == "devstack" ]]; then # Install devstack
# Warn if release chosen is not master or named-releaser # Warn if release chosen is not master or open-release (Eucalyptus and up)
if [[ $release != "master" && $release != *"named-release"* ]]; then if [[ $release != "master" && $release != *"open-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}" echo -e "${WARN}The release you entered is not 'master' or an open-release. Please be aware that a branch other than master or a release other than the latest open-release could cause errors when installing $stack.${NC}"
fi fi
wiki_link="https://openedx.atlassian.net/wiki/display/OpenOPS/Running+Devstack" wiki_link="https://openedx.atlassian.net/wiki/display/OpenOPS/Running+Devstack"
mkdir -p devstack mkdir devstack
cd devstack cd devstack
curl -L https://raw.githubusercontent.com/edx/configuration/${OPENEDX_RELEASE}/vagrant/release/devstack/Vagrantfile > Vagrantfile curl -L https://raw.githubusercontent.com/edx/configuration/${OPENEDX_RELEASE}/vagrant/release/devstack/Vagrantfile > Vagrantfile
vagrant plugin install vagrant-vbguest vagrant plugin install vagrant-vbguest
elif [[ $stack == "fullstack" ]]; then # Install fullstack elif [[ $stack == "fullstack" ]]; then # Install fullstack
# Warn if release chosen is not named-release # Warn if release chosen is not open-release (Eucalyptus and up)
if [[ $release != *"named-release"* ]]; then if [[ $release != *"open-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}" echo -e "${WARN}The release you entered is not an open-release. Please be aware that a branch other than the latest open-release could cause errors when installing $stack.${NC}"
fi fi
wiki_link="https://openedx.atlassian.net/wiki/display/OpenOPS/Running+Fullstack" wiki_link="https://openedx.atlassian.net/wiki/display/OpenOPS/Running+Fullstack"
mkdir -p fullstack mkdir fullstack
cd fullstack cd fullstack
curl -L https://raw.githubusercontent.com/edx/configuration/${OPENEDX_RELEASE}/vagrant/release/fullstack/Vagrantfile > Vagrantfile curl -L https://raw.githubusercontent.com/edx/configuration/${OPENEDX_RELEASE}/vagrant/release/fullstack/Vagrantfile > Vagrantfile
vagrant plugin install vagrant-hostsupdater vagrant plugin install vagrant-hostsupdater
...@@ -161,12 +153,12 @@ fi ...@@ -161,12 +153,12 @@ fi
vagrant up --provider virtualbox vagrant up --provider virtualbox
# Check if preview mode was chosen # Check if preview mode was chosen
if [[ $enable_preview != 1 ]] || grep -q '192.168.33.10 preview.localhost' /etc/hosts; then if grep -q '192.168.33.10 preview.localhost' /etc/hosts; then
echo "Studio preview already enabled, skipping..." echo "Studio preview already enabled, skipping..."
else else
echo "Enabling use of preview within Studio..." 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 fi
echo -e "${SUCCESS}Finished installing! You may now login using 'vagrant ssh'" echo -e "${SUCCESS}Finished installing! You may now 'cd $stack' and login using 'vagrant ssh'"
echo -e "Refer to the edX wiki ("$wiki_link") for more information on using "$stack".${NC}" 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