Fixes for vagrant up

vagrant:
  - check actual IP;
  - only init machine first time, just as native installations;
  - add .bash_profile to permissions fixup;
  - cleanup excessive newlines in making .bash_profile;

README:
  - include admin & debugging use;
  - info about re-initializing VM & manually running create-dev-env.sh;
  - add django admin & debug_toolbar setting info

Conflicts:
	AUTHORS
	scripts/vagrant-provisioning.sh
This commit is contained in:
Yarko Tymciurak
2013-07-11 18:59:08 -05:00
committed by David Baumgold
parent 679b118ed3
commit 3991711edb
3 changed files with 187 additions and 110 deletions

View File

@@ -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 -e "\n. /home/vagrant/.bashrc\n" >> ~vagrant/.bash_profile
}
# Load .bashrc ################################################################
([[ -f ~vagrant/.bash_profile ]] && grep ".bashrc" ~vagrant/.bash_profile) || {
echo ". /home/vagrant/.bashrc" >> ~vagrant/.bash_profile
}
# Virtualenv - Always load ####################################################
# Virtualenv - Always load ####################################################
([[ -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
}
([[ -f ~vagrant/.bash_profile ]] && grep "edx-platform/bin/activate" ~vagrant/.bash_profile) || {
echo ". /home/vagrant/.virtualenvs/edx-platform/bin/activate" >> ~vagrant/.bash_profile
}
# Directory ###################################################################
# Directory ###################################################################
grep "cd /opt/edx/edx-platform" ~vagrant/.bash_profile || {
echo -e "\ncd /opt/edx/edx-platform\n" >> ~vagrant/.bash_profile
}
grep "cd /opt/edx/edx-platform" ~vagrant/.bash_profile || {
echo "cd /opt/edx/edx-platform" >> ~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]
=> http://192.168.20.40:8000/
- Studio:
$ rake cms[dev,0.0.0.0:8001]
=> http://192.168.20.40:8001/
See the README for details.
EOF
} # End on_create() ########################################################
## only initialize / setup the development environment once:
# we create node_modules, so that's a good test:
[[ -d /opt/edx/node_modules ]] || on_create
# 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}')
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/
- Start Studio:
$ rake cms[dev,0.0.0.0:8001]
=> http://${MY_IP}:8001/
See the README for more.
EOF