-## Completing the Virtual Machine with Fabric
-
-*Notice* Fabric might not run properly if you presently in a virtualenv.
-`deactivate` prior to running fab commands.
-
-### From the Host Machine
-
-If Fabric is available on the host machine, you should be able to run Fabric
-commands directly on the host machine, pointed at the virtual machine. If
-Fabric is not available on the Host Machine, see the next section.
-
-To setup the host machine properly, see the section about
-[accessing the VM via fabric](#accessing-the-vm-via-fabric) and then return to
-this section.
-
-Assuming those steps were followed with the alias, the following instructions
-should complete the virtual machine setup:
-
-1. `cd {project_root}` on the host machine.
-
-1. type `vmfab first_deploy`.
-
-### From within the Virtual Machine
-
-If Fabric is not available on the host machine, or just for funsies, you may
-run the Fabric commands within the virtual machine.
-
-1. Connect to the virtual machine with `vagrant ssh`.
-
-1. On the virtual machine, type `cd karmanotes` to get into the code
- repository.
-
-1. In the code repo of the VM, type `fab -H 127.0.0.1 first_deploy`
-
- During this process, you will be queried to create a Django site admin.
- Provide information. You will be asked to remove duplicate schools. Respond
- with yes.
-
-# Production Install
-
-These steps are taken care of by automatic utilities. Vagrant performs the
-first subsection of these instructions and Fabric performs the second
-subsection. These instructions are detailed here for good measure, but should
-not generally be needed.
-
-1. Ensure the following are installed:
- * `git`
- * `7zip` (for unzipping US Department of Education files)
- * `PostgreSQL` (server and client)
- * `nginx`
- * `libxslt` and `libxml2` (used by some Python libraries)
- * `RabbitMQ` (server)
- * `memcached`
- * `Python`
- * `PIP`
- * `virtualenv`
- * `virtualenvwrapper` (might not be needed anymore)
- * `pdf2htmlEX`
-
- On a Debian system supporting Apt, this can be done with:
-```
- sudo apt-get install python-pip postgresql python-virtualenv nginx \
- virtualenvwrapper git libxml2-dev p7zip-full \
- postgresql-server-dev-9.1 libxslt1-dev \
- libmemcached-dev python-dev rabbitmq-server \
- cmake libpng-dev libjpeg-dev libgtk2.0-dev \
- pkg-config libfontconfig1-dev autoconf libtool
-
- wget http://poppler.freedesktop.org/poppler-0.24.4.tar.xz
- tar xf poppler-0.24.4.tar.xz
- cd poppler-0.24.4
- ./configure --prefix=/usr --enable-xpdf-headers
- make
- sudo make install
- cd ~/
-
- git clone https://github.com/fontforge/fontforge.git
- cd fontforge
- ./bootstrap
- ./configure --prefix=/usr
- make
- sudo make install
- cd ~/
-
- git clone https://github.com/charlesconnell/pdf2htmlEX.git
- cd pdf2htmlEX
- ./configure --prefix=/usr
- cmake .
- make
- sudo make install
-```
-
-1. Generate a PostgreSQL database and a role with read/write permissions.
- * For Debian, these instructions are helpful: https://wiki.debian.org/PostgreSql
-
-1. Modify configuration files.
- * There are settings in `{project_root}/karmaworld/settings/prod.py`
- * Most of the setting should work fine by default.
- * There are additional configuration options for external dependencies
- under `{project_root}/karmaworld/secret/`.
- 1. Copy files with the example extension to the corresponding filename
- without the example extension (e.g.
- `cp filepicker.py.example filepicker.py`)
- 1. Modify those files.
- * Ensure `PROD_DB_USERNAME`, `PROD_DB_PASSWORD`, and `PROD_DB_NAME`
- inside `db_settings.py` match the role, password, and database
- generated in the previous step.
- 1. Copy the Google Drive service account p12 file to `drive.p12`
- (this filename and location may be changed in `drive.py`)
- 1. Ensure `*.py` in `secret/` are never added to the git repo.
- (.gitignore should help warn against taking this action)
-
-1. Make sure that /var/www exists, is owned by the www-data group, and that
- the desired user is a member of the www-data group.
-
-1. Configure nginx with a `proxy_pass` to port 8000 (or whatever port gunicorn
- will be running the site on) and any virtual hosting that is desired.
- Here is an example server file to put into `/etc/nginx/sites-available/`
-
- server {
- listen 80;
- server_name localhost;
- return 301 https://$host$request_uri;
- }
-
- server {
- listen 443;
- ssl on;
- server_name localhost;
- client_max_body_size 20M;
-
- location / {
- # pass traffic through to gunicorn
- proxy_pass http://127.0.0.1:8000;
- # pass HTTP(S) status through to Django
- proxy_set_header X-Forwarded-SSL $https;
- proxy_set_header X-Forwarded-Protocol $scheme;
- proxy_set_header X-Forwarded-Proto $scheme;
- # pass nginx site back to Django
- proxy_set_header Host $http_host;
- }
- }
-
-1. Configure the system to start supervisor on boot. An init script for
- supervisor is in the repo at `{project_root}/karmaworld/confs/supervisor`.
- `update-rc.d supervisor defaults` is the Debian command to load the init
- script into the correct directories.
-
-1. Make sure `{project_root)/var/log` and `{project_root}/var/run` exist and
- may be written to, or else put the desired logging and run file paths into
- `{project_root}/confs/prod/supervisord.conf`
-
-1. Create a virtualenv under `/var/www/karmaworld/venv`
-
-1. Change into the virtualenv with `. /var/www/karmaworld/venv/bin/activate`.
- Within the virtualenv:
-
- 1. Update the Python depenencies with `pip -i {project_root}/reqs/prod.txt`
- * If you want debugging on a production-like system:
- 1. run `pip -i {project_root}/reqs/vmdev.txt`
- 1. change `{project_root}/manage.py` to point at `vmdev.py`
- instead of `prod.py`
- 1. ensure firefox is installed on the system (such as by
- `sudo apt-get install firefox`)
-
- 1. Setup the database with `python {project_root}/manage.py syncdb --migrate`
-
- 1. Collect static resources and put them in the static hosting location with
- `python {project_root}/manage.py collect_static`
-
-1. The database needs to be populated with schools. A list of accredited schools
- may be found on the US Department of Education website:
- http://ope.ed.gov/accreditation/GetDownloadFile.aspx
-
- Alternatively, use the built-in scripts while in the virtualenv: