summaryrefslogtreecommitdiff
path: root/docker/tbp
diff options
context:
space:
mode:
authorMartin Miller2020-12-10 18:17:07 -0600
committerMartin Miller2020-12-10 18:17:07 -0600
commit015b9cb1b2f808624ae693327090aa8514438226 (patch)
tree7a4ab4557fb2e196c2b6b19743dae526d4f9d3bd /docker/tbp
downloadtbp-015b9cb1b2f808624ae693327090aa8514438226.zip
tbp-015b9cb1b2f808624ae693327090aa8514438226.tar.gz
Initial commitHEADmaster
Diffstat (limited to 'docker/tbp')
-rw-r--r--docker/tbp/Dockerfile34
-rw-r--r--docker/tbp/LICENSE21
-rw-r--r--docker/tbp/README.md74
-rw-r--r--docker/tbp/bashlib-current.tar.gzbin0 -> 19626 bytes
-rw-r--r--docker/tbp/docker-compose.yml15
-rw-r--r--docker/tbp/etc/lighttpd/lighttpd.conf329
-rw-r--r--docker/tbp/etc/lighttpd/mime-types.conf79
-rw-r--r--docker/tbp/etc/lighttpd/mod_cgi.conf32
-rw-r--r--docker/tbp/etc/lighttpd/mod_fastcgi.conf17
-rw-r--r--docker/tbp/etc/lighttpd/mod_fastcgi_fpm.conf16
-rwxr-xr-xdocker/tbp/tbpReport.sh67
-rw-r--r--docker/tbp/visitlog/Makefile30
-rw-r--r--docker/tbp/visitlog/style.css10
-rw-r--r--docker/tbp/visitlog/visitlog.sh191
14 files changed, 915 insertions, 0 deletions
diff --git a/docker/tbp/Dockerfile b/docker/tbp/Dockerfile
new file mode 100644
index 0000000..5b47402
--- /dev/null
+++ b/docker/tbp/Dockerfile
@@ -0,0 +1,34 @@
+# Dockerfile for lighttpd
+
+FROM alpine
+
+ENV TZ=America/Chicago
+COPY bashlib-current.tar.gz /root
+RUN apk add --update --no-cache \
+ bash \
+ lighttpd \
+ lighttpd-mod_auth \
+ tzdata \
+ && cd /root \
+ && tar zxvf bashlib-current.tar.gz \
+ && cd bashlib-0.4 \
+ && ./configure \
+ && cp bashlib /usr/local/bin \
+ && rm -rf /root/* \
+ && mkdir -p /var/www/localhost/cgi-bin \
+ && rm -rf /var/cache/apk/* \
+ && cp /usr/share/zoneinfo/America/Chicago /etc/localtime
+
+## workaround for bug preventing sync between VirtualBox and host
+# http://serverfault.com/questions/240038/lighttpd-broken-when-serving-from-virtualbox-shared-folder
+RUN echo server.network-backend = \"writev\" >> /etc/lighttpd/lighttpd.conf
+
+COPY etc/lighttpd/* /etc/lighttpd/
+
+EXPOSE 80
+
+COPY visitlog/visitlog.sh /var/www/localhost/cgi-bin/visitlog.cgi
+COPY visitlog/style.css /var/www/localhost/htdocs/
+RUN chmod 555 /var/www/localhost/cgi-bin/visitlog.cgi
+
+CMD ["lighttpd", "-D", "-f", "/etc/lighttpd/lighttpd.conf"]
diff --git a/docker/tbp/LICENSE b/docker/tbp/LICENSE
new file mode 100644
index 0000000..11bac33
--- /dev/null
+++ b/docker/tbp/LICENSE
@@ -0,0 +1,21 @@
+The MIT License (MIT)
+
+Copyright (c) 2015 Sébastien Pujadas
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+THE SOFTWARE.
diff --git a/docker/tbp/README.md b/docker/tbp/README.md
new file mode 100644
index 0000000..85dc4b1
--- /dev/null
+++ b/docker/tbp/README.md
@@ -0,0 +1,74 @@
+# lighttpd Docker image
+
+Security, speed, compliance, and flexibility -- all of these describe [lighttpd](http://www.lighttpd.net/)
+
+### Contents
+
+ - Usage
+ - Start a container with Docker
+ - Start a container with Docker Compose
+ - Build
+ - Build with Docker
+ - Build with Docker Compose
+ - About
+
+## Usage
+
+In the instructions that follow, replace:
+
+- `<home-directory>` with the path of the local directory you want to serve content from.
+
+- `<config-directory>` with the path of the local directory containing lighttpd configuration files that you want to use instead of the default ones.
+
+ To make it easier to create custom configuration files, the default configuration files are included in the `etc/lighttpd` directory of the Git repository.
+
+- `<http-port>` with the HTTP port you want the HTTP server to serve content to (e.g. `80` for the standard HTTP port if not already in use on the host).
+
+### Start a container with Docker
+
+With the default configuration files:
+
+ $ sudo docker run --rm -t -v <home-directory>:/var/www/localhost/htdocs -p <http-port>:80 sebp/lighttpd
+
+With custom configuration files:
+
+ $ sudo docker run --rm -t -v <home-directory>:/var/www/localhost/htdocs -v <config-directory>:/etc/lighttpd -p <http-port>:80 sebp/lighttpd
+
+### Start a container with Docker Compose
+
+Add the following lines in an existing or a new `docker-compose.yml` file:
+
+ lighttpd:
+ image: sebp/lighttpd
+ volumes:
+ - <home-directory>:/var/www/localhost/htdocs
+ - <config-directory>:/etc/lighttpd
+ ports:
+ - "<http-port>:80"
+
+**Note** – The `- <config-directory>:…` line is optional, it can be used to override the default configuration files with your own.
+
+Then start a lighttpd container with:
+
+ $ sudo docker-compose up lighttpd
+
+
+## Build
+
+First clone or download the [spujadas/lighttpd-docker](https://github.com/spujadas/lighttpd-docker) GitHub repository, open a shell in the newly created `lighttpd-docker` directory, then build the image and run a container using Docker or Docker Compose, as explained below.
+
+### Build with Docker
+
+This command will build the image:
+
+ $ sudo docker build .
+
+### Build with Docker Compose
+
+Build the image with this command:
+
+ $ sudo docker-compose build
+
+## About
+
+Written by [Sébastien Pujadas](http://pujadas.net), released under the [MIT license](http://opensource.org/licenses/MIT).
diff --git a/docker/tbp/bashlib-current.tar.gz b/docker/tbp/bashlib-current.tar.gz
new file mode 100644
index 0000000..eec2e78
--- /dev/null
+++ b/docker/tbp/bashlib-current.tar.gz
Binary files differ
diff --git a/docker/tbp/docker-compose.yml b/docker/tbp/docker-compose.yml
new file mode 100644
index 0000000..8fc1a08
--- /dev/null
+++ b/docker/tbp/docker-compose.yml
@@ -0,0 +1,15 @@
+# Docker Compose YAML file for lighttpd
+
+# build with:
+# $ sudo docker-compose build
+
+# start with:
+# $ sudo docker-compose up
+
+# after start, enter shell with:
+# $ sudo docker exec -it lighttpddocker_lighttpd_1 ash
+
+lighttpd:
+ build: .
+ ports:
+ - "8001:80" # for testing purposes, (un)comment as required
diff --git a/docker/tbp/etc/lighttpd/lighttpd.conf b/docker/tbp/etc/lighttpd/lighttpd.conf
new file mode 100644
index 0000000..cb0297d
--- /dev/null
+++ b/docker/tbp/etc/lighttpd/lighttpd.conf
@@ -0,0 +1,329 @@
+###############################################################################
+# Default lighttpd.conf for Gentoo.
+# $Header: /var/cvsroot/gentoo-x86/www-servers/lighttpd/files/conf/lighttpd.conf,v 1.3 2005/09/01 14:22:35 ka0ttic Exp $
+###############################################################################
+
+# {{{ variables
+var.basedir = "/var/www/localhost"
+var.logdir = "/var/log/lighttpd"
+var.statedir = "/var/lib/lighttpd"
+# }}}
+
+# {{{ modules
+# At the very least, mod_access and mod_accesslog should be enabled.
+# All other modules should only be loaded if necessary.
+# NOTE: the order of modules is important.
+server.modules = (
+ "mod_rewrite",
+# "mod_redirect",
+ "mod_alias",
+ "mod_access",
+# "mod_cml",
+# "mod_trigger_b4_dl",
+# "mod_auth",
+# "mod_status",
+# "mod_setenv",
+# "mod_proxy",
+# "mod_simple_vhost",
+# "mod_evhost",
+# "mod_userdir",
+# "mod_compress",
+# "mod_ssi",
+# "mod_usertrack",
+# "mod_expire",
+# "mod_secdownload",
+# "mod_rrdtool",
+# "mod_webdav",
+ "mod_accesslog"
+)
+# }}}
+
+# {{{ includes
+include "mime-types.conf"
+# uncomment for cgi support
+ include "mod_cgi.conf"
+# uncomment for php/fastcgi support
+# include "mod_fastcgi.conf"
+# uncomment for php/fastcgi fpm support
+# include "mod_fastcgi_fpm.conf"
+# }}}
+
+# {{{ server settings
+server.username = "lighttpd"
+server.groupname = "lighttpd"
+
+server.document-root = var.basedir + "/htdocs"
+server.pid-file = "/run/lighttpd.pid"
+
+server.errorlog = var.logdir + "/error.log"
+# log errors to syslog instead
+# server.errorlog-use-syslog = "enable"
+
+server.indexfiles = ("index.php", "index.html",
+ "index.htm", "default.htm")
+
+# server.tag = "lighttpd"
+
+server.follow-symlink = "enable"
+
+# event handler (defaults to "poll")
+# see performance.txt
+#
+# for >= linux-2.4
+# server.event-handler = "linux-rtsig"
+# for >= linux-2.6
+# server.event-handler = "linux-sysepoll"
+# for FreeBSD
+# server.event-handler = "freebsd-kqueue"
+
+# chroot to directory (defaults to no chroot)
+# server.chroot = "/"
+
+# bind to port (defaults to 80)
+# server.port = 81
+
+# bind to name (defaults to all interfaces)
+# server.bind = "grisu.home.kneschke.de"
+
+# error-handler for status 404
+# server.error-handler-404 = "/error-handler.html"
+# server.error-handler-404 = "/error-handler.php"
+
+# Format: <errorfile-prefix><status-code>.html
+# -> ..../status-404.html for 'File not found'
+# server.errorfile-prefix = var.basedir + "/error/status-"
+
+# FAM support for caching stat() calls
+# requires that lighttpd be built with USE=fam
+# server.stat-cache-engine = "fam"
+# }}}
+
+# {{{ mod_staticfile
+
+# which extensions should not be handled via static-file transfer
+# (extensions that are usually handled by mod_cgi, mod_fastcgi, etc).
+static-file.exclude-extensions = (".cgi")
+# }}}
+
+# {{{ mod_accesslog
+accesslog.filename = var.logdir + "/access.log"
+# }}}
+
+# {{{ mod_dirlisting
+# enable directory listings
+# dir-listing.activate = "enable"
+#
+# don't list hidden files/directories
+# dir-listing.hide-dotfiles = "enable"
+#
+# use a different css for directory listings
+# dir-listing.external-css = "/path/to/dir-listing.css"
+#
+# list of regular expressions. files that match any of the
+# specified regular expressions will be excluded from directory
+# listings.
+# dir-listing.exclude = ("^\.", "~$")
+# }}}
+
+# {{{ mod_access
+# see access.txt
+
+url.access-deny = ("~", ".inc")
+# }}}
+
+# {{{ mod_userdir
+# see userdir.txt
+#
+# userdir.path = "public_html"
+# userdir.exclude-user = ("root")
+# }}}
+
+# {{{ mod_ssi
+# see ssi.txt
+#
+# ssi.extension = (".shtml")
+# }}}
+
+# {{{ mod_ssl
+# see ssl.txt
+#
+# ssl.engine = "enable"
+# ssl.pemfile = "server.pem"
+# }}}
+
+# {{{ mod_status
+# see status.txt
+#
+# status.status-url = "/server-status"
+# status.config-url = "/server-config"
+# }}}
+
+# {{{ mod_simple_vhost
+# see simple-vhost.txt
+#
+# If you want name-based virtual hosting add the next three settings and load
+# mod_simple_vhost
+#
+# document-root =
+# virtual-server-root + virtual-server-default-host + virtual-server-docroot
+# or
+# virtual-server-root + http-host + virtual-server-docroot
+#
+# simple-vhost.server-root = "/home/weigon/wwwroot/servers/"
+# simple-vhost.default-host = "grisu.home.kneschke.de"
+# simple-vhost.document-root = "/pages/"
+# }}}
+
+# {{{ mod_compress
+# see compress.txt
+#
+# compress.cache-dir = var.statedir + "/cache/compress"
+# compress.filetype = ("text/plain", "text/html")
+# }}}
+
+# {{{ mod_proxy
+# see proxy.txt
+#
+# proxy.server = ( ".php" =>
+# ( "localhost" =>
+# (
+# "host" => "192.168.0.101",
+# "port" => 80
+# )
+# )
+# )
+# }}}
+
+# {{{ mod_auth
+# see authentication.txt
+#
+# auth.backend = "plain"
+# auth.backend.plain.userfile = "lighttpd.user"
+# auth.backend.plain.groupfile = "lighttpd.group"
+
+# auth.backend.ldap.hostname = "localhost"
+# auth.backend.ldap.base-dn = "dc=my-domain,dc=com"
+# auth.backend.ldap.filter = "(uid=$)"
+
+# auth.require = ( "/server-status" =>
+# (
+# "method" => "digest",
+# "realm" => "download archiv",
+# "require" => "user=jan"
+# ),
+# "/server-info" =>
+# (
+# "method" => "digest",
+# "realm" => "download archiv",
+# "require" => "valid-user"
+# )
+# )
+# }}}
+
+# {{{ mod_rewrite
+# see rewrite.txt
+#
+# url.rewrite = (
+# "^/$" => "/server-status"
+# )
+# }}}
+
+# {{{ mod_redirect
+# see redirect.txt
+#
+# url.redirect = (
+# "^/wishlist/(.+)" => "http://www.123.org/$1"
+# )
+# }}}
+
+# {{{ mod_evhost
+# define a pattern for the host url finding
+# %% => % sign
+# %0 => domain name + tld
+# %1 => tld
+# %2 => domain name without tld
+# %3 => subdomain 1 name
+# %4 => subdomain 2 name
+#
+# evhost.path-pattern = "/home/storage/dev/www/%3/htdocs/"
+# }}}
+
+# {{{ mod_expire
+# expire.url = (
+# "/buggy/" => "access 2 hours",
+# "/asdhas/" => "access plus 1 seconds 2 minutes"
+# )
+# }}}
+
+# {{{ mod_rrdtool
+# see rrdtool.txt
+#
+# rrdtool.binary = "/usr/bin/rrdtool"
+# rrdtool.db-name = var.statedir + "/lighttpd.rrd"
+# }}}
+
+# {{{ mod_setenv
+# see setenv.txt
+#
+# setenv.add-request-header = ( "TRAV_ENV" => "mysql://user@host/db" )
+# setenv.add-response-header = ( "X-Secret-Message" => "42" )
+# }}}
+
+# {{{ mod_trigger_b4_dl
+# see trigger_b4_dl.txt
+#
+# trigger-before-download.gdbm-filename = "/home/weigon/testbase/trigger.db"
+# trigger-before-download.memcache-hosts = ( "127.0.0.1:11211" )
+# trigger-before-download.trigger-url = "^/trigger/"
+# trigger-before-download.download-url = "^/download/"
+# trigger-before-download.deny-url = "http://127.0.0.1/index.html"
+# trigger-before-download.trigger-timeout = 10
+# }}}
+
+# {{{ mod_cml
+# see cml.txt
+#
+# don't forget to add index.cml to server.indexfiles
+# cml.extension = ".cml"
+# cml.memcache-hosts = ( "127.0.0.1:11211" )
+# }}}
+
+# {{{ mod_webdav
+# see webdav.txt
+#
+# $HTTP["url"] =~ "^/dav($|/)" {
+# webdav.activate = "enable"
+# webdav.is-readonly = "enable"
+# }
+# }}}
+
+# {{{ extra rules
+#
+# set Content-Encoding and reset Content-Type for browsers that
+# support decompressing on-thy-fly (requires mod_setenv)
+# $HTTP["url"] =~ "\.gz$" {
+# setenv.add-response-header = ("Content-Encoding" => "x-gzip")
+# mimetype.assign = (".gz" => "text/plain")
+# }
+
+# $HTTP["url"] =~ "\.bz2$" {
+# setenv.add-response-header = ("Content-Encoding" => "x-bzip2")
+# mimetype.assign = (".bz2" => "text/plain")
+# }
+#
+# }}}
+#
+url.rewrite-once = (
+ "^/style.css" => "", # get style.css from htdocs
+ "^/(.*)$" => "/cgi-bin/visitlog.cgi/$1" # forward others to cgi
+)
+
+# {{{ debug
+# debug.log-request-header = "enable"
+# debug.log-response-header = "enable"
+# debug.log-request-handling = "enable"
+# debug.log-file-not-found = "enable"
+# }}}
+
+# vim: set ft=conf foldmethod=marker et :
+server.network-backend = "writev"
diff --git a/docker/tbp/etc/lighttpd/mime-types.conf b/docker/tbp/etc/lighttpd/mime-types.conf
new file mode 100644
index 0000000..f24d4d8
--- /dev/null
+++ b/docker/tbp/etc/lighttpd/mime-types.conf
@@ -0,0 +1,79 @@
+###############################################################################
+# Default mime-types.conf for Gentoo.
+# include'd from lighttpd.conf.
+# $Header: /var/cvsroot/gentoo-x86/www-servers/lighttpd/files/conf/mime-types.conf,v 1.4 2010/03/14 21:45:18 bangert Exp $
+###############################################################################
+
+# {{{ mime types
+mimetype.assign = (
+ ".svg" => "image/svg+xml",
+ ".svgz" => "image/svg+xml",
+ ".pdf" => "application/pdf",
+ ".sig" => "application/pgp-signature",
+ ".spl" => "application/futuresplash",
+ ".class" => "application/octet-stream",
+ ".ps" => "application/postscript",
+ ".torrent" => "application/x-bittorrent",
+ ".dvi" => "application/x-dvi",
+ ".gz" => "application/x-gzip",
+ ".pac" => "application/x-ns-proxy-autoconfig",
+ ".swf" => "application/x-shockwave-flash",
+ ".tar.gz" => "application/x-tgz",
+ ".tgz" => "application/x-tgz",
+ ".tar" => "application/x-tar",
+ ".zip" => "application/zip",
+ ".dmg" => "application/x-apple-diskimage",
+ ".mp3" => "audio/mpeg",
+ ".m3u" => "audio/x-mpegurl",
+ ".wma" => "audio/x-ms-wma",
+ ".wax" => "audio/x-ms-wax",
+ ".ogg" => "application/ogg",
+ ".wav" => "audio/x-wav",
+ ".gif" => "image/gif",
+ ".jpg" => "image/jpeg",
+ ".jpeg" => "image/jpeg",
+ ".png" => "image/png",
+ ".xbm" => "image/x-xbitmap",
+ ".xpm" => "image/x-xpixmap",
+ ".xwd" => "image/x-xwindowdump",
+ ".css" => "text/css",
+ ".html" => "text/html",
+ ".htm" => "text/html",
+ ".js" => "text/javascript",
+ ".asc" => "text/plain",
+ ".c" => "text/plain",
+ ".h" => "text/plain",
+ ".cc" => "text/plain",
+ ".cpp" => "text/plain",
+ ".hh" => "text/plain",
+ ".hpp" => "text/plain",
+ ".conf" => "text/plain",
+ ".log" => "text/plain",
+ ".text" => "text/plain",
+ ".txt" => "text/plain",
+ ".diff" => "text/plain",
+ ".patch" => "text/plain",
+ ".ebuild" => "text/plain",
+ ".eclass" => "text/plain",
+ ".rtf" => "application/rtf",
+ ".bmp" => "image/bmp",
+ ".tif" => "image/tiff",
+ ".tiff" => "image/tiff",
+ ".ico" => "image/x-icon",
+ ".dtd" => "text/xml",
+ ".xml" => "text/xml",
+ ".mpeg" => "video/mpeg",
+ ".mpg" => "video/mpeg",
+ ".mov" => "video/quicktime",
+ ".qt" => "video/quicktime",
+ ".avi" => "video/x-msvideo",
+ ".asf" => "video/x-ms-asf",
+ ".asx" => "video/x-ms-asf",
+ ".wmv" => "video/x-ms-wmv",
+ ".bz2" => "application/x-bzip",
+ ".tbz" => "application/x-bzip-compressed-tar",
+ ".tar.bz2" => "application/x-bzip-compressed-tar"
+ )
+# }}}
+
+# vim: set ft=conf foldmethod=marker et :
diff --git a/docker/tbp/etc/lighttpd/mod_cgi.conf b/docker/tbp/etc/lighttpd/mod_cgi.conf
new file mode 100644
index 0000000..f56415f
--- /dev/null
+++ b/docker/tbp/etc/lighttpd/mod_cgi.conf
@@ -0,0 +1,32 @@
+###############################################################################
+# mod_cgi.conf
+# include'd by lighttpd.conf.
+# $Header: /var/cvsroot/gentoo-x86/www-servers/lighttpd/files/conf/mod_cgi.conf,v 1.1 2005/08/27 12:36:13 ka0ttic Exp $
+###############################################################################
+
+#
+# see cgi.txt for more information on using mod_cgi
+#
+
+server.modules += ("mod_cgi")
+
+# NOTE: this requires mod_alias
+alias.url = (
+ "/cgi-bin/" => var.basedir + "/cgi-bin/"
+)
+
+#
+# Note that you'll also want to enable the
+# cgi-bin alias via mod_alias (above).
+#
+
+$HTTP["url"] =~ "^/cgi-bin/" {
+ # disable directory listings
+ dir-listing.activate = "disable"
+ # only allow cgi's in this directory
+ cgi.assign = (
+ ".cgi" => "/bin/bash"
+ )
+}
+
+# vim: set ft=conf foldmethod=marker et :
diff --git a/docker/tbp/etc/lighttpd/mod_fastcgi.conf b/docker/tbp/etc/lighttpd/mod_fastcgi.conf
new file mode 100644
index 0000000..549b84c
--- /dev/null
+++ b/docker/tbp/etc/lighttpd/mod_fastcgi.conf
@@ -0,0 +1,17 @@
+###############################################################################
+# mod_fastcgi.conf
+# include'd by lighttpd.conf.
+# $Header: /var/cvsroot/gentoo-x86/www-servers/lighttpd/files/conf/mod_fastcgi.conf-1.4.13-r2,v 1.1 2007/04/01 23:22:00 robbat2 Exp $
+###############################################################################
+
+server.modules += ("mod_fastcgi")
+fastcgi.server = ( ".php" =>
+ ( "localhost" =>
+ (
+ "socket" => "/run/lighttpd/lighttpd-fastcgi-php-" + PID + ".socket",
+ "bin-path" => "/usr/bin/php-cgi"
+ )
+ )
+ )
+
+# vim: set ft=conf foldmethod=marker et :
diff --git a/docker/tbp/etc/lighttpd/mod_fastcgi_fpm.conf b/docker/tbp/etc/lighttpd/mod_fastcgi_fpm.conf
new file mode 100644
index 0000000..926137a
--- /dev/null
+++ b/docker/tbp/etc/lighttpd/mod_fastcgi_fpm.conf
@@ -0,0 +1,16 @@
+###############################################################################
+# mod_fastcgi_fpm.conf
+# include'd by lighttpd.conf.
+###############################################################################
+
+server.modules += ("mod_fastcgi")
+fastcgi.server = ( ".php" =>
+ ( "localhost" =>
+ (
+ "host" => "127.0.0.1",
+ "port" => "9000"
+ )
+ )
+ )
+
+# vim: set ft=conf foldmethod=marker et :
diff --git a/docker/tbp/tbpReport.sh b/docker/tbp/tbpReport.sh
new file mode 100755
index 0000000..bb7bc44
--- /dev/null
+++ b/docker/tbp/tbpReport.sh
@@ -0,0 +1,67 @@
+#!/bin/bash
+# tbpReport.sh
+# 2020/12/08
+# Write a report for the last week, month, or year.
+USAGE="Usage: $0 [-w] [-m] [-y] visitFile"
+
+if [ "$#" == "0" ]; then
+ echo $USAGE
+ exit 1
+fi
+
+# Get start time from arguments
+startTime=0
+while [ $# -gt 1 ]; do
+ case $1 in
+ -w)
+ startTime=`date --date="1 week ago" +%s`
+ ;;
+ -m)
+ startTime=`date --date="1 month ago" +%s`
+ ;;
+ -y)
+ startTime=`date --date="1 year ago" +%s`
+ ;;
+ *)
+ echo $USAGE
+ exit 1
+ ;;
+ esac
+ shift
+done
+
+# Test if visits file exists
+if [ ! -f $1 ]; then
+ echo "File $1 does not exist."
+ echo $USAGE
+ exit 1
+fi
+visitFile=$1
+
+# Process the visits file
+echo Shop report for `date +%D`
+echo Shop access since `date --date=@$startTime +%D`
+awk -F, -v t=$startTime '($1>t) {
+ dow=strftime("%w", $1);
+ counter[dow,$6]+=1;
+ counter[$6]+=1;
+ counter[$4]+=1;
+ counter[$5]+=1;
+ numVisitors+=1;
+}
+END {
+ printf("%-10s\tDowntown\tCampus\n", "");
+ printf("%-10s\t%3d\t\t%3d\n", "Sunday", counter[0, "downtown"], counter[0,"campus"]);
+ printf("%-10s\t%3d\t\t%3d\n", "Monday", counter[1, "downtown"], counter[1,"campus"]);
+ printf("%-10s\t%3d\t\t%3d\n", "Tuesday", counter[2, "downtown"], counter[2,"campus"]);
+ printf("%-10s\t%3d\t\t%3d\n", "Wednesday", counter[3, "downtown"], counter[3,"campus"]);
+ printf("%-10s\t%3d\t\t%3d\n", "Thursday", counter[4, "downtown"], counter[4,"campus"]);
+ printf("%-10s\t%3d\t\t%3d\n", "Friday", counter[5, "downtown"], counter[5,"campus"]);
+ printf("%-10s\t%3d\t\t%3d\n", "Saturday", counter[6, "downtown"], counter[6,"campus"]);
+ printf("-------------------------------------\n")
+ printf("%-10s\t%3d\t\t%3d\n", "TOTAL", counter["downtown"], counter["campus"]);
+ printf("\n")
+ printf("Total volunteer visits: %d\n", counter["volunteer"]);
+ printf("Total first visits: %d (%0.1f%%)\n", counter["First Visit"],
+ 100*counter["First Visit"]/numVisitors);
+}' $visitFile
diff --git a/docker/tbp/visitlog/Makefile b/docker/tbp/visitlog/Makefile
new file mode 100644
index 0000000..cca34cd
--- /dev/null
+++ b/docker/tbp/visitlog/Makefile
@@ -0,0 +1,30 @@
+INSTALLDIR = /usr/lib/cgi-bin
+CSSDIR = /home/marty/public_html
+LOGDIR = /var/www/visitlog
+FIRSTTIME = firsttime.txt
+PAGE = visitlog.sh
+VISITS = visits.csv
+MEMBERS = members.csv
+WWWUSER = www-data
+WWWGROUP = www-data
+
+.PHONY install:
+install:
+ touch $(LOGDIR)/$(VISITS)
+ touch $(LOGDIR)/$(FIRSTTIME)
+ cp $(MEMBERS) $(LOGDIR)
+ cp $(PAGE) $(INSTALLDIR)
+ cp style.css $(CSSDIR)
+ chmod 400 $(CSSDIR)/style.css
+ chmod 400 $(LOGDIR)/$(MEMBERS)
+ chmod 600 $(LOGDIR)/$(VISITS)
+ chmod 600 $(LOGDIR)/$(FIRSTTIME)
+ chmod 500 $(INSTALLDIR)/$(PAGE)
+ chown $(WWWUSER).$(WWWGROUP) $(LOGDIR)/$(MEMBERS)
+ chown $(WWWUSER).$(WWWGROUP) $(LOGDIR)/$(VISITS)
+ chown $(WWWUSER).$(WWWGROUP) $(LOGDIR)/$(FIRSTTIME)
+ chown $(WWWUSER).$(WWWGROUP) $(INSTALLDIR)/$(PAGE)
+ chown $(WWWUSER).$(WWWGROUP) $(CSSDIR)/style.css
+
+.PHONY clean:
+clean:
diff --git a/docker/tbp/visitlog/style.css b/docker/tbp/visitlog/style.css
new file mode 100644
index 0000000..57c7e97
--- /dev/null
+++ b/docker/tbp/visitlog/style.css
@@ -0,0 +1,10 @@
+
+h1 {
+ text-transform: capitalize;
+}
+
+h2,h3,tr {
+ text-transform: capitalize;
+}
+
+
diff --git a/docker/tbp/visitlog/visitlog.sh b/docker/tbp/visitlog/visitlog.sh
new file mode 100644
index 0000000..b169ee5
--- /dev/null
+++ b/docker/tbp/visitlog/visitlog.sh
@@ -0,0 +1,191 @@
+#!/usr/bin/env bash
+# visitlog.sh
+# Martin Miller
+# Created: 2017/09/04
+# A CGI script for the bike project visitors log
+. /usr/local/bin/bashlib
+memberFile=/var/www/visitlog/members.csv
+visitorLog=/var/www/visitlog/visits.csv
+firstVisitLog=/var/www/visitlog/firsttime.txt
+
+# Determine if we know the location
+location=`cookie location`
+locationp=`param location`
+if [ -z ${location} ]
+then
+ if [ -z ${locationp} ]
+ then
+ # Ask for location
+ /bin/echo "Content-Type: text/html; charset=utf-8"
+ /bin/echo ""
+/bin/cat <<EOF
+<body>
+<h1>Please select your location</h1>
+<form method="post" autocomplete="off">
+Downtown<input type="radio" name="location" value="downtown" checked>
+Campus<input type="radio" name="location" value="campus" ><br />
+<input type="submit" value="Submit">
+</form>
+EOF
+exit
+ else
+ /bin/echo "Set-Cookie: location=${locationp}"
+ location=${locationp}
+ fi
+fi
+/bin/echo "Content-Type: text/html; charset=utf-8"
+/bin/echo ""
+
+d0=$(/bin/date +%Y-%m-%d)
+datestring=$(/bin/date +"%B %d, %Y")
+t0=$(/bin/date --date="$d0" +%s)
+/bin/cat <<EOF
+<html>
+<head>
+<link rel="stylesheet" type="text/css" href="style.css" />
+<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">
+</head>
+<body>
+<div class="container-fluid">
+<div class="col-xs-12 col-sm-6">
+<h1>The Bike Project Visitor Log</h1>
+</div>
+<div class="col-xs-12 col-sm-6">
+<h3><span class="glyphicon glyphicon-map-marker" aria-hidden="true"></span> ${location} Shop</h3>
+<h3><span class="glyphicon glyphicon-calendar" aria-hidden="true"></span> ${datestring}</h3>
+</div>
+<div class="clearfix"></div>
+EOF
+# Check for sign in
+cardno=`param cardno`
+visittype=`param visittype`
+if [ ${#cardno} -ge 4 ]
+then
+ # check if cardno is valid member
+ awk -F, -v cn=$cardno -v vl=$visitorLog -v loc=$location -v vt=$visittype '
+ BEGIN {
+ intid=0;
+ found=0;
+ valid=0;
+ goodtil=0;
+ now=systime();
+ first="";
+ lastI=""
+ }
+ # The second field of the member file stores the external constituent ID
+ # surrounded by double quotes.
+ ($2=="\""cn"\"") {
+ # The eighth field stores the membership expiration in YYYY-MM-DD,
+ # convert to YYYY MM DD
+ found=1
+ gsub("\"","",$1)
+ intid=$1
+ gsub("\"","",$3)
+ first=$3
+ gsub("\"","",$4)
+ lastI=substr($4,1,3)
+ gsub("\"","",$8)
+ goodtil=$8;
+ gsub("-"," ",$8)
+ exptime=mktime($8" 23 59 59")
+ if (exptime>now) {
+ valid=1
+ }
+ }
+ END {
+ if (found==0) {
+ exit 1
+ }
+ if (valid==1) {
+ gsub("\"","",$1);
+ printf("<div class=\"alert alert-success\">Hello %s %s! Your membership is valid until %s.</div>", first, lastI, goodtil);
+ printf("%d,%s,%s,%s,%s,%s\n",now,cn,intid,first" "lastI".",vt,loc) >> vl
+ exit 0
+ } else {
+ printf("<div class=\"alert alert-danger\">Hello %s %s. your membership expired on %s. Please see a staff member to renew.</div>", first, lastI, goodtil);
+ exit 2
+ }
+ }' $memberFile
+fi
+
+if [ $? -eq 1 ] # User not found in member database
+then
+ hashed=$(echo $cardno | sha256sum | cut -d' ' -f1)
+ grep "${hashed}" $firstVisitLog > /dev/null
+ if [ $? -eq 0 ]
+ then
+/bin/cat <<EOF
+<div class="alert alert-danger">You have used your one free visit. If you would like to
+use the shop, please contact a staff member to become a member</div>
+EOF
+ else
+/bin/cat <<EOF
+<div class="alert alert-warning">Welcome to The Bike Project. Please enjoy your free trial
+visit.</div>
+EOF
+ echo ${hashed} >> $firstVisitLog
+ now=$(date +"%s")
+ echo ${now},-1,-1,First Visit,visitor,$location >> $visitorLog
+ fi
+fi
+
+if [ -z $cardno ] && [ $visittype = "volunteer" ]
+then
+/bin/cat <<EOF
+<div class="alert alert-warning">I didn't quite catch that. Could you scan your
+card again? In the future, you can avoid this message by clicking the text box
+after you click "Volunteering".</div>
+EOF
+fi
+
+# Display visitors and form
+/bin/cat <<EOF
+<div class="row">
+<div class="col-xs-12 col-sm-4">
+<div class="panel panel-default">
+<div class="panel-heading">Sign in</div>
+<div class="panel-body">
+<form method="post" autocomplete="off">
+<div class="form-group">
+<p class="col-xs-3">I am</p>
+EOF
+if [ -z $cardno ] && [ $visittype = "volunteer" ]
+then
+/bin/cat <<EOF
+<input type="radio" name="visittype" value="visitor" >Visiting<br>
+<input type="radio" name="visittype" value="volunteer" checked>Volunteering
+EOF
+else
+/bin/cat <<EOF
+<input type="radio" name="visittype" value="visitor" checked>Visiting<br>
+<input type="radio" name="visittype" value="volunteer" >Volunteering
+EOF
+fi
+/bin/cat <<EOF
+<input type="text" class="form-control" name="cardno" autofocus=autofocus>
+</div>
+<button type="submit" class="btn btn-primary">Submit</button>
+</form>
+</div>
+</div>
+</div>
+<div class="col-xs-12 col-sm-8">
+<table class="table table-striped">
+<tr>
+<th>Time</th>
+<th>Name</th>
+<th>Visit Type</th>
+</tr>
+EOF
+/usr/bin/tac $visitorLog | /usr/bin/awk -F, -v to=$t0 -v loc=$location '($1>to && $6==loc) {
+ printf("<tr><td>%s</td><td>%s</td><td>%s</td></tr>\n", strftime("%r", $1),
+ $4,$5)
+}'
+
+/bin/cat <<EOF
+</table>
+</div>
+</body>
+</html>
+EOF
+