Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Comparing changes

Choose two branches to see what's changed or to start a new pull request. If you need to, you can also compare across forks.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also compare across forks.
...
Checking mergeability… Don't worry, you can still create the pull request.
  • 3 commits
  • 5 files changed
  • 0 commit comments
  • 1 contributor
View
19 doc/deploy-dev.md
@@ -0,0 +1,19 @@
+# Deploying tollgate in development #
+
+In development, you can run and deploy `tollgate` from within a git clone of the repository. This is the "old" way of deploying tollgate in production, and has since been superceeded.
+
+You can run tollgate in development either out of a WSGI-compatible webserver, or using Django's single-threaded development server.
+
+## Useful Functions ##
+
+### repair_permissions ###
+
+ $ python manage.py repair_permissions
+
+Repairs execute permissions on scripts.
+
+### setup_settings ###
+
+ $ python manage.py setup_settings
+
+Creates a `tollgate/settings/local.py` for your local settings, and configures your `SECRET_KEY`.
View
132 doc/deploy-djp.md
@@ -0,0 +1,132 @@
+# Deploying tollgate into a Django project #
+
+The "proper" way to deploy tollgate is to install the software (using `setup.py`), and then create a Django project with tollgate setup inside of it.
+
+This is achieveable fairly simply, however be aware that **tollgate only manages routing**, it does **not** manage things like DNS and DHCP which you'll need to make your network actually accept clients.
+
+This has the advantage of allowing you to easily customise configuration and templates. Be aware though that all modifications to tollgate **must** be made available, as well as the software itself, to all of your users, as a condition of the license.
+
+## Pre-requisites ##
+
+I'm assuming here that you have:
+
+ * Installed and configured an apache2 server with mod_wsgi and mod_ssl.
+ * Installed and configured a database server, for example, MySQL, as well as installed appropriate Python bindings to allow interaction.
+ * Installed everything else you need to make your network work -- that is, DHCP server, DNS server, multiple network interfaces in your tollgate machine (which will be your router / default gateway).
+ * Installed and configured DBUS.
+ * Installed other dependencies.
+
+Installation and configuration of those is outside of the scope of this document. If you're looking up HOWTO documents on the internet, do not do anything with `iptables`, as setting up a NAT and routing itself is part of tollgate.
+
+## Install `tollgate` ##
+
+Install tollgate, either using an official stable build, git repository, or distribution package. You can install the latest `master` version of tollgate using `pip` with this command:
+
+ $ sudo pip install git+https://github.com/micolous/tollgate.git
+
+This **may** not work though, as the state of `git master` may be in flux.
+
+This will install the entire `tollgate` package into your Python path, and install the captivity and backend daemons.
+
+## Configure DBUS ##
+
+We need to add some configuration files for tollgate to DBUS' configuration in order to allow the web server process to use tollgate's backend.
+
+In `example/dbus/system.d/tollgate.conf` are some example configuration you can use with tollgate. Copy this to `/etc/dbus-1/system.d/`, and modify with the appropriate username that the webserver uses (if it is not `www-data`).
+
+Then reload the DBUS configuration with `/etc/init.d/dbus reload`.
+
+## Create a project ##
+
+Now, you should create a Django project for tollgate to use. This won't have any of tollgate's code in this folder -- it will reference a the system-installed copy.
+
+ $ django-admin startproject mylanportal
+
+This will create some boilerplate code for a Django site. Currently, tollgate doesn't support not being at the root of the site, but this may change in the future.
+
+From here on in, I'm going to assume your project name is `mylanportal`.
+
+## Configure the project ##
+
+Jump into the `mylanportal/mylanportal/urls.py`. Change it so it includes `tollgate.urls`. `tollgate.urls` will also give you the Django admin site, and the internationalisation configuration app. It should look something like this:
+
+ from django.conf.urls import patterns, include, url
+ urlpatterns = patterns('',
+ (r'^', include('tollgate.urls')),
+ )
+
+The next step is to setup `settings.py`.
+
+Near the top, add these lines:
+
+ from os.path import *
+ PROJECT_PATH = realpath(dirname(__file__))
+
+This is a handy trick because you can use it to setup other paths later.
+
+Setup the location of the database. It is recommended you use MariaDB (MySQL).
+
+You should also setup a `STATIC_ROOT` for where all the static files should be served from, and a `STATIC_URL`. Be aware that if you are deploying on a HTTPS site (which you should!) you need to make your resources also be on a HTTPS site. The purpose of this is that outside of DEBUG mode, you're expected to serve static files external to Django -- as it is much faster.
+
+To your `MIDDLEWARE_CLASSES`, add `tollgate.frontend.common.TollgateMiddleware`,
+
+To your `INSTALLED_APPS`, append `south`, `tollgate.api`, `tollgate.frontend`, and `tollgate.scripts`.
+
+You should also add the following extra settings for tollgate and configure appropriately:
+
+ LAN_SUBNET='10.4.0.0/23'
+ LAN_IFACE='eth1'
+ DEFAULT_QUOTA_AMOUNT=150
+ RESET_EXCUSE_REQUIRED=True
+ RESET_PURCHASE=False
+ ONLY_CONSOLE=False
+ RESTRICTED_CALLS_KEY=''
+ LOGIN_URL='/login/'
+ LOGOUT_URL='/logout/'
+
+The final setting to add is a URL where you are hosting the tollgate sources with your modifications. You should **never** link back to the official tollgate repository using this method (there is already a link to the official repo on the source page).
+
+Not hosting the source code yourself may expose you to legal liability.
+
+## Configure daemons ##
+
+Install the init scripts and backend configuration:
+
+ $ sudo cp platform/debian/init.d/* /etc/init.d/
+ $ sudo cp platform/debian/default/* /etc/default/
+ $ sudo mkdir /etc/tollgate/
+ $ sudo cp example/tollgate/backend.ini /etc/tollgate/
+
+Modify the scripts (`tollgate-backend` and `tollgate-captivity`) as appropriate to match the path to the tollgate_backend and tollgate_captivity scripts.
+
+Edit `/etc/default/tollgate-captivity` to point to the URL where tollgate is hosted.
+
+To make the daemons start, run:
+
+ $ sudo update-rc.d tollgate-backend defaults
+ $ sudo update-rc.d tollgate-captivity defaults
+
+Modify the backend configuration as appropriate for your network (`/etc/tollgate/backend.ini`).
+
+We won't start the daemons just yet, though.
+
+## Configure cron ##
+
+tollgate requires a periodic cronjob to refresh the list of hosts in it's database.
+
+An example configuration is given in `examples/tollgate.cron`. You will need to adapt it to point to the path of your Django project.
+
+## Configure webserver ##
+
+You'll need to now configure your web server. You may wish to copy `tollgate/tollgate.wsgi` and use it in your own project folder.
+
+There is an example apache2 configuration, including all vhosts, in `example/apache2/tollgate-vhost`.
+
+You will need to modify the path of static items (like the WPAD and WFC vhosts, and aliases for static files) to the appropriate locations, and URLs.
+
+Included in the examples is how to configure a gitweb instance. You could also push code changes to an external repository, however it must be accessible to users at all times (ie: you should mark it as "unmetered").
+
+## Start the daemons ##
+
+The first time you run you'll need to manually start the daemons. They will start automatically on next boot.
+
View
2  example/tollgate/backend.ini
@@ -71,7 +71,7 @@ enable = yes
; captive_landing/index.py
;
; You should change this as appropriate for your setup
-port = 81
+port = 50080
[unmetered]
; These sites are always accessible and are unmetered.
View
2  tollgate/backend/tollgate_backend.py
@@ -40,7 +40,7 @@
},
'captive': {
'enable': True,
- 'port': 81
+ 'port': 50080
}
}
View
4 tollgate/captive_landing/tproxy.py
@@ -83,8 +83,8 @@ def main_optparse():
parser = OptionParser(usage="%prog [-D] -l 'https://tollgate.example.com'")
parser.add_option('-D', '--daemon', action='store_true', dest='daemon', help='start as a daemon')
parser.add_option('-l', '--tollgate-uri', dest='tollgate_uri', metavar='URI', help='root URI of tollgate frontend HTTPS server')
- parser.add_option('-p', '--port', dest='port', type='int', metavar='PORT', help='port of the tproxy service', default=50080)
- parser.add_option('-m', '--mark', dest='mark', type='int', metavar='MARK', help='TPROXY mark tag for this service', default=1)
+ parser.add_option('-p', '--port', dest='port', type='int', metavar='PORT', help='port of the tproxy service [default: %default]', default=50080)
+ parser.add_option('-m', '--mark', dest='mark', type='int', metavar='MARK', help='TPROXY mark tag for this service [default: %default]', default=1)
options, args = parser.parse_args()
if not options.tollgate_uri:

No commit comments for this range

Something went wrong with that request. Please try again.