init
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
Simon Bruder 2019-03-24 14:09:53 +01:00
commit 5f8c1ccd36
6 changed files with 162 additions and 0 deletions

13
.drone.yml Normal file
View file

@ -0,0 +1,13 @@
kind: pipeline
name: default
steps:
- name: docker
image: plugins/docker
settings:
registry: r.sbruder.de
username:
from_secret: docker_username
password:
from_secret: docker_password
repo: r.sbruder.de/lighttpd

13
Dockerfile Normal file
View file

@ -0,0 +1,13 @@
FROM alpine
RUN apk add --no-cache \
ca-certificates \
lighttpd \
lighttpd-mod_auth \
lighttpd-mod_webdav
COPY lighttpd.conf /etc/lighttpd/lighttpd.conf
COPY assets /etc/lighttpd/assets
COPY entrypoint.sh /entrypoint.sh
ENTRYPOINT ["/entrypoint.sh"]

48
assets/listing.css Normal file
View file

@ -0,0 +1,48 @@
body,html {
background-color: #fdf6e3;
color: #657b83;
font-family: "TeX Gyre Heros", "Roboto", "Helvetica", "Arial", sans-serif;
}
tr:nth-child(even) {
background: #eee8d5;
}
th,td {
padding: 0.1em 0.5em;
}
th {
text-align: left;
font-weight: bold;
background: #eee8d5;
border-bottom: 1px solid #657b83;
}
a {
color: #586e75;
}
a:hover {
color: #073642;
}
.m, .t {
display: none;
}
table {
width: 100%;
}
.foot {
display: none;
}
#search-field {
width: 100%;
border: none;
margin-bottom: 15px;
background: #eee8d5;
color: inherit;
}

27
assets/listing.js Normal file
View file

@ -0,0 +1,27 @@
let searchField = document.createElement('input')
searchField.id = 'search-field'
searchField.autofocus = true
document.querySelector('.list').insertBefore(searchField, document.querySelector('table'))
try {
document.querySelector('a[href="../"]').innerText = '..'
} catch (e) {}
const rows = [...document.querySelectorAll('tbody tr')]
document.querySelector('#search-field').addEventListener("input", e => {
const searchValue = e.target.value.toLowerCase()
rows.forEach(row => {
const file = row.querySelector('td').innerText
if (!file.toLowerCase().startsWith(searchValue)) {
row.style.display = 'none'
} else {
row.style.display = 'table-row'
}
})
const visibleRows = [...document.querySelectorAll('tr[style="display: table-row;"]')]
if (visibleRows.length === 1) {
window.location = visibleRows[0].querySelector('td a').href
}
})

9
entrypoint.sh Executable file
View file

@ -0,0 +1,9 @@
#!/bin/ash
sed -i \
-e "s/@@LDAP_SERVER@@/$LDAP_SERVER/" \
-e "s/@@LDAP_BASE@@/$LDAP_BASE/" \
-e "s/@@LDAP_USER@@/$LDAP_USER/" \
-e "s/@@LDAP_PASSWORD@@/$LDAP_PASSWORD/" \
/etc/lighttpd/lighttpd.conf
lighttpd -D -f /etc/lighttpd/lighttpd.conf

52
lighttpd.conf Normal file
View file

@ -0,0 +1,52 @@
server.modules = (
"mod_alias",
"mod_webdav",
"mod_auth",
"mod_authn_ldap",
)
include "mime-types.conf"
server.username = "lighttpd"
server.groupname = "lighttpd"
server.document-root = "/srv/www"
server.indexfiles = ("index.html", "index.htm")
server.follow-symlink = "enable"
alias.url = ("/directory-listing-assets/" => "/etc/lighttpd/assets/")
dir-listing.activate = "enable"
dir-listing.encoding = "utf-8"
dir-listing.external-css = "/directory-listing-assets/listing.css"
dir-listing.external-js = "/directory-listing-assets/listing.js"
webdav.activate = "enable"
webdav.is-readonly = "enable"
auth.backend = "ldap"
auth.backend.ldap.hostname = "@@LDAP_SERVER@@"
auth.backend.ldap.base-dn = "@@LDAP_BASE@@"
auth.backend.ldap.filter = "(uid=$)"
auth.backend.ldap.starttls = "enable"
auth.backend.ldap.bind-dn = "@@LDAP_USER@@"
auth.backend.ldap.bind-pw = "@@LDAP_PASSWORD@@"
#auth.require = ( "/" =>
# (
# "method" => "basic",
# "realm" => "media",
# "require" => "valid-user"
# )
# )
$HTTP["url"] !~ "^/directory-listing-assets/" {
auth.require = ( "" =>
(
"method" => "basic",
"realm" => "media",
"require" => "valid-user"
)
)
}