diff --git a/README.md b/README.md index 31bfc69..4e60797 100644 --- a/README.md +++ b/README.md @@ -88,7 +88,7 @@ cd /mnt/PORTALKEY/FreedomPortal Once inside the folder, run the following command : ``` -lua configure.lua config +lua configure.lua parameters ``` Then, finalize the installation by running : diff --git a/configure.lua b/configure.lua index fae1361..5b79889 100644 --- a/configure.lua +++ b/configure.lua @@ -12,6 +12,10 @@ end local lustache = require('lustache') local config = require(arg[1]) +-- Add `last` attribute to last site to help templates +config.sites[table.getn(config.sites)].last = true +config.first_site = config.sites[1] + -- Helpers function run_command(cmd) local process = assert(io.popen(cmd, 'r')) diff --git a/freedomportal/lighttpd.conf b/freedomportal/lighttpd.conf index 1fb5395..fbd279e 100644 --- a/freedomportal/lighttpd.conf +++ b/freedomportal/lighttpd.conf @@ -17,7 +17,7 @@ server.port = 80 {{# config.page_404_path }} server.error-handler-404 = "{{{ config.page_404_path }}}" {{/ config.page_404_path }} -server.document-root = "{{{ config.www_dir }}}" +server.document-root = "{{{ config.first_site.www_dir }}}" server.pid-file = "/var/run/lighttpd.pid" include "/etc/lighttpd/mime.conf" @@ -28,39 +28,39 @@ index-file.names = ( "index.html" ) server.errorlog = "{{{ config.log_dir }}}/error.log" # stderr output from CGI processes server.breakagelog = "{{{ config.log_dir }}}/server-error.log" -# logging visitors -{{# config.log_visitors }} -$HTTP["host"] == "{{{ config.www_host }}}" { - $HTTP["url"] == "/" { - accesslog.filename = "{{{ config.log_dir }}}/visitors.log" - accesslog.format = "%t %h \"%{User-Agent}i\"" - } -} -{{/ config.log_visitors }} # Lua files are handled with cgi cgi.assign = ( ".lua" => "{{{ wsapi_cgi_bin }}}" ) -# Serve the redirection page to all requests that are made to a different host -# than "{{{ config.www_host }}}" -$HTTP["host"] !~ "^{{{ config.www_host }}}$" { +# Serve the redirection page to all requests that are made to an unknown host +$HTTP["host"] !~ "{{# config.sites }}(^{{{ www_host }}}$){{^last}}|{{/last}}{{/ config.sites }}" { url.rewrite-once = ( "(.*)" => "/redirection.html" ) alias.url = ( "" => "{{{ config.configured_dir }}}/pages/", ) + + {{# config.log_visitors }} + $HTTP["url"] == "/redirection.html" { + accesslog.filename = "{{{ config.log_dir }}}/visitors.log" + accesslog.format = "%t %h \"%{User-Agent}i\"" + } + {{/ config.log_visitors }} } -# All static content is hosted at "{{{ config.www_host }}}" -# Routes under {{{ config.scripts_root_url }}} serve lua scripts -$HTTP["host"] == "{{{ config.www_host }}}" { +{{# config.sites }} +# All static content is hosted at {{{ www_host }}}/ +# Routes under {{{ www_host }}}{{{ scripts_root_url }}} serve lua scripts +$HTTP["host"] == "{{{ www_host }}}" { alias.url = ( - "{{{ config.scripts_root_url }}}" => "{{{ config.configured_dir }}}/scripts", - "" => "{{{ config.www_dir }}}", + "{{{ scripts_root_url }}}" => "{{{ config.configured_dir }}}/scripts", + "" => "{{{ www_dir }}}", ) } +{{/ config.sites }} + {{# config.ios_disable_cna }} # Return `success.html` page if CaptiveNetworkSupport request, so iOS device # thinks it's connected and won't pop-up the CNA. diff --git a/freedomportal/pages/redirection.html b/freedomportal/pages/redirection.html index de2fd00..06a7ab9 100644 --- a/freedomportal/pages/redirection.html +++ b/freedomportal/pages/redirection.html @@ -2,11 +2,11 @@ Connecting ... - +

- To finish connecting, go to this page. + To finish connecting, go to this page.

diff --git a/parameters.lua.template b/parameters.lua.template index fdc028d..d554bfb 100644 --- a/parameters.lua.template +++ b/parameters.lua.template @@ -1,26 +1,44 @@ return { - -- Host on which lighttpd will serve custom web pages - www_host = 'freedomportal.com', + landing_page = 'http://freedomportal.com/', - -- Root url for serving scripts - scripts_root_url = '/_scripts', + sites = { + { + -- Host on which lighttpd will serve custom web pages + www_host = 'freedomportal.com', - -- Path where the configured files are saved - configured_dir = '/root/FreedomPortal_configured', + -- Root path for the custom web pages served on the static portal + www_dir = '/mnt/PORTALKEY/www', - -- Root path for the custom web pages served on the static portal - www_dir = '/mnt/PORTALKEY/www', + -- Root url for serving scripts + scripts_root_url = '/_scripts' + }, + }, - -- [Optional] path to a 404 page which will be displayed if the user - -- tries to load a non-existent page. The configured path is relative to `www_dir`. - page_404_path = '/404.html', + wireless = { + -- Public name of the wifi network. + -- NOTE : Max length of SSID is 32 characters! + ssid = 'FreedomPortal', + + -- Encryption type of the network. Set to "psk-mixed" to setup a password. + encryption = 'none', + + -- Password. Useless if encryption is 'none' + key = 'password' + }, + + -- Path where the configured files are saved + configured_dir = '/root/FreedomPortal_configured', -- Root path for all log files -- NOTE : files under /var are erased when the router reboots. If you don't want to loose -- your logs, place them somewhere else, for example on the USB key (e.g. /mnt/PORTALKEY/log) log_dir = '/var/log/lighttpd', + -- [Optional] path to a 404 page which will be displayed if the user + -- tries to load a non-existent page. The configured path is relative to `www_dir`. + page_404_path = '/404.html', + -- Set to true to log visitor's access log_visitors = false, @@ -37,15 +55,4 @@ return { -- disable it, even if it means the user has to open their browser manually. ios_disable_cna = false, - wireless = { - -- Public name of the wifi network. - -- NOTE : Max length of SSID is 32 characters! - ssid = 'FreedomPortal', - - -- Encryption type of the network. Set to "psk-mixed" to setup a password. - encryption = 'none', - - -- Password. Useless if encryption is 'none' - key = 'password' - } }