diff --git a/AUTHORS b/AUTHORS index 89fc2d959b3f8e9cbaa3fabe98d2b2233423c31c..c700eab277642cb5751a88dd6e6b9e610760aaa5 100644 --- a/AUTHORS +++ b/AUTHORS @@ -82,3 +82,5 @@ Adam Palay <adam@edx.org> Ian Hoover <ihoover@edx.org> Mukul Goyal <miki@edx.org> Robert Marks <rmarks@edx.org> +Yarko Tymciurak <yarkot1@gmail.com> + diff --git a/README.md b/README.md index 2208fe1cada1c439f5ccd8b4fbd440043d57d1e4..efa2c78640692472f32a526fe01384c47c750443 100644 --- a/README.md +++ b/README.md @@ -12,30 +12,35 @@ installation process. 1. Make sure you have plenty of available disk space, >5GB 2. Install Git: http://git-scm.com/downloads -3. Install VirtualBox: https://www.virtualbox.org/wiki/Download_Old_Builds_4_2 - (you need version 4.2.12, as later/earlier versions might not work well with - Vagrant) +3. Install VirtualBox: https://www.virtualbox.org/wiki/Downloads + See http://docs.vagrantup.com/v2/providers/index.html for a list of supported + Providers. You should use VirtualBox >= 4.2.12. + (Windows: later/earlier VirtualBox versions than 4.2.12 have been reported to not work well with + Vagrant. If this is still a problem, you can + install 4.2.12 from https://www.virtualbox.org/wiki/Download_Old_Builds_4_2). 4. Install Vagrant: http://www.vagrantup.com/ (Vagrant 1.2.2 or later) 5. Open a terminal 6. Download the project: `git clone git://github.com/edx/edx-platform.git` 7. Enter the project directory: `cd edx-platform/` 8. (Windows only) Run the commands to [deal with line endings and symlinks under Windows](https://github.com/edx/edx-platform/wiki/Simplified-install-with-vagrant#dealing-with-line-endings-and-symlinks-under-windows) -9. Start: `vagrant up` +9. Create the development environment and start it: `vagrant up` -The last step might require your host machine's administrator password to setup NFS. +The initial `vagrant up` will download a Linux image, then boot and ask for your +host machine's administrator password to setup file sharing between your computer and the VM. +Once file sharing is established, `edx-platform/scripts/create-dev-env.sh` will +install dependencies and configure the VM. +This will take a while; go grab a coffee. -Afterwards, it will download an image, install all the dependencies and configure -the VM. It will take a while, go grab a coffee. +When complete, you should see a _"Success!"_ message. +If not, refer to the +[troubleshooting section](https://github.com/edx/edx-platform/wiki/Simplified-install-with-vagrant#troubleshooting). -Once completed, hopefully you should see a "Success!" message indicating that the -installation went fine. (If not, refer to the -[troubleshooting section](https://github.com/edx/edx-platform/wiki/Simplified-install-with-vagrant#troubleshooting).) +Your development environment is initialized only on the first bring-up. +Subsequently `vagrant up` commands will boot your virtual machine normally. -Note: by default, the VM will get the IP `192.168.20.40`. If you need to use a -different IP, you can edit the file `Vagrantfile`. If you have already started the -VM with `vagrant up`, see "Stopping and restarting the VM" below to take the change -into account. +Note: by default, the VM will get the IP `192.168.20.40`. +You can change this in your `Vagrantfile` (the startup message will reflect your VM's actual IP). Accessing the VM ---------------- @@ -46,15 +51,24 @@ Once the installation is finished, to log into the virtual machine: $ vagrant ssh ``` -Note: This won't work from Windows, install install PuTTY from -http://www.chiark.greenend.org.uk/%7Esgtatham/putty/download.html instead. Then -connect to 127.0.0.1, port 2222, using vagrant/vagrant as a user/password. +Note: This won't work from Windows. Instead, install PuTTY from +http://www.chiark.greenend.org.uk/%7Esgtatham/putty/download.html. Then +connect to 192.168.20.40, port 2222, using vagrant/vagrant as a user/password. + Using edX --------- -Once inside the VM, you can start Studio and LMS with the following commands -(from the `/opt/edx/edx-platform` folder): +When you login to your VM, you are in +`/opt/edx/edx-platform` by default, which is shared from your host workspace. +Your host computer contains the edx-project development code and repository. +Your VM runs edx-platform code mounted from your host, so +you can develop by editing on your host. + +After logging into your VM with `vagrant ssh`, +start the _Studio_ and +_Learning management system (LMS)_ +servers (run these from `/opt/edx/edx-platform`): Learning management system (LMS): @@ -62,46 +76,85 @@ Learning management system (LMS): $ rake lms[cms.dev,0.0.0.0:8000] ``` -Studio: +Studio (CMS): ``` $ rake cms[dev,0.0.0.0:8001] ``` -Once started, open the following URLs in your browser: +The servers will come up to these URLs: -* Learning management system (LMS): http://192.168.20.40:8000/ -* Studio (CMS): http://192.168.20.40:8001/ +- LMS: http://192.168.20.40:8000/ +- CMS: http://192.168.20.40:8001/ -You can develop by editing the files directly in the `edx-platform/` directory you -downloaded before, you don't need to connect to the VM to edit them (the VM uses -those files to run edX, mirroring the folder in `/opt/edx/edx-platform`). +Your VM's port 8000 is forwarded to host port 9000 +so you can also access the LMS with [http://localhost:9000/](). +Similarly, VM port 8001 is forwarded to host port 9001. +These are set in your `Vagrantfile`. -You may also want to create a super-user with: - -``` -$ rake django-admin["createsuperuser"] -``` - -Also note that if you register a new user through the web interface, -the activiation email will be posted to your VM's terminal window (search for -lines similar to): +Note that when you register a new user through the web interface, +by default the activiation email will be appear on your VM's terminal. +Search for lines similar to: ``` Subject: Your account for edX Studio From: registration@edx.org ``` -and find the activation URL for the account you've created. +and find the activation URL. See the [Frequently Asked Questions](https://github.com/edx/edx-platform/wiki/Frequently-Asked-Questions) for more usage tips. +Django admin & debug toolbar +----------------------------- + +You can enable admin logins and the debug_toolbar by editing +`lms/envs/common.py`: + +- enable ADMIN login page by setting: + - ``` + 'ENABLE_DJANGO_ADMIN_SITE': True +``` + + +- enable debug toolbar by uncommenting: + - ``` + # 'debug_toolbar.middleware.DebugToolbarMiddleware', +``` + +These are also defined in `lms/envs/dev.py`, +and usually active on localhost. + +To get at your VM's 127.0.0.1, explicitly forward one of VM's available localhost ports to your computer. +Instead of `vagrant ssh`, login with: + +``` +$ ssh -L 6080:127.0.0.1:8080 vagrant@192.168.20.40 +``` + +The password is _vagrant_. + +From your VM, start the LMS as a localhost instance: + +``` +$ rake lms[cms.dev,127.0.0.1:8080] +``` + +You should see the debug toolbar now on [http:/localhost:6080/](). +You should now also see a login on [http://localhost:6080/admin/]() +You will need a privileged user for the admin login. +You can create a CMS/LMS super-user with: +``` +$ rake django-admin["createsuperuser"] +``` + + Stopping & starting ------------------- -To stop the VM (from your `edx-platform/` directory): +To stop the VM (from your `edx-platform/` directory): ``` $ vagrant halt ``` @@ -112,12 +165,23 @@ To restart: $ vagrant up ``` -or, to start without attempting to update the dependencies: +To suspend and resume tasks in progress on your VM: +``` +$ vagrant suspend +$ # and later... +$ vagrant resume +``` +Your development environment is normally created once, on first `vagrant up`. +You can continue to fetch changes in edx-platform +as you work with your VM. +To re-create your VM and create a fresh development environment: ``` -$ vagrant up --no-provision +$ vagrant destroy +$ vagrant up # will make a new VM ``` + Troubleshooting --------------- diff --git a/scripts/vagrant-provisioning.sh b/scripts/vagrant-provisioning.sh index d4f627b2c432b789682bc56d192b5224a67ed610..0243cd36aec091319a25f3cfbbcfe975710ad7b7 100755 --- a/scripts/vagrant-provisioning.sh +++ b/scripts/vagrant-provisioning.sh @@ -4,6 +4,7 @@ # # Authors: Xavier Antoviaque <xavier@antoviaque.org> # David Baumgold <david@davidbaumgold.com> +# Yarko Tymciurak <yarkot1@gmail.com> # # This software's license gives you freedom; you can copy, convey, # propagate, redistribute and/or modify this program under the terms of @@ -30,102 +31,112 @@ # # This script is ran by `$ vagrant up`, see the README for more explanations +on_create() +{ + # APT - Packages ############################################################## -# APT - Packages ############################################################## + apt-get update + apt-get install -y python-software-properties vim -apt-get update -apt-get install -y python-software-properties vim + # Curl - No progress bar ###################################################### -# Curl - No progress bar ###################################################### + [[ -f ~vagrant/.curlrc ]] || echo "silent show-error" > ~vagrant/.curlrc + chown vagrant.vagrant ~vagrant/.curlrc -[[ -f ~vagrant/.curlrc ]] || echo "silent show-error" > ~vagrant/.curlrc -chown vagrant.vagrant ~vagrant/.curlrc + # SSH - Known hosts ########################################################### -# SSH - Known hosts ########################################################### + # Github + ([[ -f ~vagrant/.ssh/known_hosts ]] && grep "zBX7bKA= ssh" ~vagrant/.ssh/known_hosts) || { + echo "|1|4DtBcMsTM4zgl/jTS7h3ZkmS/Vc=|XkRnn2xEhr8ixOxeskJAzBX7bKA= ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEAq2A7hRGmdnm9tUDbO9IDSwBK6TbQa+PXYPCPy6rbTrTtw7PHkccKrpp0yVhp5HdEIcKr6pLlVDBfOLX9QUsyCOV0wzfjIJNlGEYsdlLJizHhbn2mUjvSAHQqZETYP81eFzLQNnPHt4EVVUh7VfDESU84KezmD5QlWpXLmvU31/yMf+Se8xhHTvKSCZIFImWwoG6mbUoWf9nzpIoaSjB+weqqUUmpaaasXVal72J+UX2B+2RPW3RcT0eOzQgqlJL3RKrTJvdsjE3JEAvGq3lGHSZXy28G3skua2SmVi/w4yCE6gbODqnTWlg7+wC604ydGXA8VJiS5ap43JXiUFFAaQ==" >> ~vagrant/.ssh/known_hosts + } + ([[ -f ~vagrant/.ssh/known_hosts ]] && grep "jO3J5bvw= ssh" ~vagrant/.ssh/known_hosts) || { + echo "|1|9rANf/qOAPgKH/TXpGuZCAgGxMs=|x9VYWEDI8kiotbhhNXqjO3J5bvw= ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEAq2A7hRGmdnm9tUDbO9IDSwBK6TbQa+PXYPCPy6rbTrTtw7PHkccKrpp0yVhp5HdEIcKr6pLlVDBfOLX9QUsyCOV0wzfjIJNlGEYsdlLJizHhbn2mUjvSAHQqZETYP81eFzLQNnPHt4EVVUh7VfDESU84KezmD5QlWpXLmvU31/yMf+Se8xhHTvKSCZIFImWwoG6mbUoWf9nzpIoaSjB+weqqUUmpaaasXVal72J+UX2B+2RPW3RcT0eOzQgqlJL3RKrTJvdsjE3JEAvGq3lGHSZXy28G3skua2SmVi/w4yCE6gbODqnTWlg7+wC604ydGXA8VJiS5ap43JXiUFFAaQ==" >> ~vagrant/.ssh/known_hosts + } + chown vagrant.vagrant ~vagrant/.ssh/known_hosts -# Github -([[ -f ~vagrant/.ssh/known_hosts ]] && grep "zBX7bKA= ssh" ~vagrant/.ssh/known_hosts) || { - echo "|1|4DtBcMsTM4zgl/jTS7h3ZkmS/Vc=|XkRnn2xEhr8ixOxeskJAzBX7bKA= ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEAq2A7hRGmdnm9tUDbO9IDSwBK6TbQa+PXYPCPy6rbTrTtw7PHkccKrpp0yVhp5HdEIcKr6pLlVDBfOLX9QUsyCOV0wzfjIJNlGEYsdlLJizHhbn2mUjvSAHQqZETYP81eFzLQNnPHt4EVVUh7VfDESU84KezmD5QlWpXLmvU31/yMf+Se8xhHTvKSCZIFImWwoG6mbUoWf9nzpIoaSjB+weqqUUmpaaasXVal72J+UX2B+2RPW3RcT0eOzQgqlJL3RKrTJvdsjE3JEAvGq3lGHSZXy28G3skua2SmVi/w4yCE6gbODqnTWlg7+wC604ydGXA8VJiS5ap43JXiUFFAaQ==" >> ~vagrant/.ssh/known_hosts -} -([[ -f ~vagrant/.ssh/known_hosts ]] && grep "jO3J5bvw= ssh" ~vagrant/.ssh/known_hosts) || { - echo "|1|9rANf/qOAPgKH/TXpGuZCAgGxMs=|x9VYWEDI8kiotbhhNXqjO3J5bvw= ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEAq2A7hRGmdnm9tUDbO9IDSwBK6TbQa+PXYPCPy6rbTrTtw7PHkccKrpp0yVhp5HdEIcKr6pLlVDBfOLX9QUsyCOV0wzfjIJNlGEYsdlLJizHhbn2mUjvSAHQqZETYP81eFzLQNnPHt4EVVUh7VfDESU84KezmD5QlWpXLmvU31/yMf+Se8xhHTvKSCZIFImWwoG6mbUoWf9nzpIoaSjB+weqqUUmpaaasXVal72J+UX2B+2RPW3RcT0eOzQgqlJL3RKrTJvdsjE3JEAvGq3lGHSZXy28G3skua2SmVi/w4yCE6gbODqnTWlg7+wC604ydGXA8VJiS5ap43JXiUFFAaQ==" >> ~vagrant/.ssh/known_hosts -} -chown vagrant.vagrant ~vagrant/.ssh/known_hosts + # edX - Development environment ############################################### -# edX - Development environment ############################################### + # Node modules require a filesystem with symlinks (Windows support) + mkdir -p /opt/edx/node_modules /opt/edx/edx-platform/node_modules + ([[ -f /etc/fstab ]] && grep '/opt/edx/node_modules' /etc/fstab) || { + echo '/opt/edx/node_modules /opt/edx/edx-platform/node_modules none bind,noauto 0 0' >> /etc/fstab + mount /opt/edx/node_modules + } + # Must be mounted *after* the NFS mount, made manually by Vagrant + ([[ -f /etc/cron.d/nodemodules ]] && grep '/opt/edx/node_modules' /etc/cron.d/nodemodules) || { + echo '@reboot root until [ -n "`mount |grep "/opt/edx/edx-platform type"`" ]; do sleep 1; done; mount /opt/edx/node_modules' > /etc/cron.d/nodemodules + } -# Node modules require a filesystem with symlinks (Windows support) -mkdir -p /opt/edx/node_modules /opt/edx/edx-platform/node_modules -([[ -f /etc/fstab ]] && grep '/opt/edx/node_modules' /etc/fstab) || { - echo '/opt/edx/node_modules /opt/edx/edx-platform/node_modules none bind,noauto 0 0' >> /etc/fstab - mount /opt/edx/node_modules -} -# Must be mounted *after* the NFS mount, made manually by Vagrant -([[ -f /etc/cron.d/nodemodules ]] && grep '/opt/edx/node_modules' /etc/cron.d/nodemodules) || { - echo '@reboot root until [ -n "`mount |grep "/opt/edx/edx-platform type"`" ]; do sleep 1; done; mount /opt/edx/node_modules' > /etc/cron.d/nodemodules -} + # Force rechecking all prerequisites (could have been fetched outside of the VM) + rm -rf /opt/edx/edx-platform/.prereqs_cache -# Force rechecking all prerequisites (could have been fetched outside of the VM) -rm -rf /opt/edx/edx-platform/.prereqs_cache + # Permissions + chown vagrant.vagrant /opt/edx /opt/edx/node_modules /opt/edx/edx-platform/node_modules -# Permissions -chown vagrant.vagrant /opt/edx /opt/edx/node_modules /opt/edx/edx-platform/node_modules + # For convenience with `vagrant ssh`, the `edx-platform` virtualenv is always + # loaded after the first run, so we need to deactivate that behavior to run + # `create-dev-env.sh`. + [[ -f ~vagrant/.bash_profile ]] && { + mv ~vagrant/.bash_profile ~vagrant/.bash_profile.bak + } + sudo -u vagrant -i bash -c "cd /opt/edx/edx-platform && PROJECT_HOME=/opt/edx ./scripts/create-dev-env.sh -ynq" -# For convenience with `vagrant ssh`, the `edx-platform` virtualenv is always -# loaded after the first run, so we need to deactivate that behavior to run -# `create-dev-env.sh`. -[[ -f ~vagrant/.bash_profile ]] && { - mv ~vagrant/.bash_profile ~vagrant/.bash_profile.bak -} -sudo -u vagrant -i bash -c "cd /opt/edx/edx-platform && PROJECT_HOME=/opt/edx ./scripts/create-dev-env.sh -ynq" + # Load .bashrc ################################################################ + ([[ -f ~vagrant/.bash_profile ]] && grep ".bashrc" ~vagrant/.bash_profile) || { + echo ". /home/vagrant/.bashrc" >> ~vagrant/.bash_profile + } -# Load .bashrc ################################################################ -([[ -f ~vagrant/.bash_profile ]] && grep ".bashrc" ~vagrant/.bash_profile) || { - echo -e "\n. /home/vagrant/.bashrc\n" >> ~vagrant/.bash_profile -} + # Virtualenv - Always load #################################################### -# Virtualenv - Always load #################################################### + ([[ -f ~vagrant/.bash_profile ]] && grep "edx-platform/bin/activate" ~vagrant/.bash_profile) || { + echo ". /home/vagrant/.virtualenvs/edx-platform/bin/activate" >> ~vagrant/.bash_profile + } -([[ -f ~vagrant/.bash_profile ]] && grep "edx-platform/bin/activate" ~vagrant/.bash_profile) || { - echo -e "\n. /home/vagrant/.virtualenvs/edx-platform/bin/activate\n" >> ~vagrant/.bash_profile -} + # Directory ################################################################### -# Directory ################################################################### + grep "cd /opt/edx/edx-platform" ~vagrant/.bash_profile || { + echo "cd /opt/edx/edx-platform" >> ~vagrant/.bash_profile + } -grep "cd /opt/edx/edx-platform" ~vagrant/.bash_profile || { - echo -e "\ncd /opt/edx/edx-platform\n" >> ~vagrant/.bash_profile -} + # Permissions + chown vagrant.vagrant ~vagrant/.bash_profile - -# End ######################################################################### - -cat << EOF + cat << EOF ============================================================================== -Success! +Success - Created your development environment! ============================================================================== -Now, from the virtual machine (connect with "vagrant ssh" if vagrant didn't -log you in already), you can start Studio & LMS with the following commands: - -- Learning management system (LMS): - $ rake lms[cms.dev,0.0.0.0:8000] +EOF +} # End on_create() ######################################################## - => http://192.168.20.40:8000/ +## only initialize / setup the development environment once: +# we create node_modules, so that's a good test: +[[ -d /opt/edx/node_modules ]] || on_create -- Studio: - $ rake cms[dev,0.0.0.0:8001] +# grab what the Vagrantfile spec'd our IP to be: +# expecting: +# - relevant ip on eth1; +# - line of interest to look like: +# inet 192.168.20.40/24 brd 192.168.20.255 scope global eth1 +MY_IP=$(ip addr show dev eth1 | sed -n '/inet /{s/.*[ ]\(.*\)\/.*/\1/;p}') - => http://192.168.20.40:8001/ +cat << EOF +Connect to your virtual machine with "vagrant ssh". +Some examples you can use from your virtual machine: +- Start Learning management system (LMS): + $ rake lms[cms.dev,0.0.0.0:8000] + => http://${MY_IP}:8000/ -See the README for details. +- Start Studio: + $ rake cms[dev,0.0.0.0:8001] + => http://${MY_IP}:8001/ +See the README for more. EOF - -