Prepare separate dirl distribution
Some checks failed
continuous-integration/drone/push Build is failing

This commit is contained in:
Armin Friedl 2020-09-01 22:50:47 +02:00
parent d3e3257464
commit 50951cafd8
7 changed files with 62 additions and 178 deletions

View file

@ -3,13 +3,20 @@ type: docker
name: default name: default
steps: steps:
- name: build - name: glibc-x86_64
image: gcc image: gcc
commands: commands:
- make - make
- mv quark quark-dirl - mv dirl dirl-glibc-x86_64
- name: publish - name: musl-x86_64
image: alpine
commands:
- apk update && apk add make git build-base linux-headers musl-dev
- make STATIC="-static -fPIE"
- mv dirl dirl-musl-x86_64
- name: publish binaries
image: appleboy/drone-scp image: appleboy/drone-scp
settings: settings:
host: friedl.net host: friedl.net
@ -18,5 +25,19 @@ steps:
password: password:
from_secret: deploy_password from_secret: deploy_password
port: 22 port: 22
target: /var/services/dirlist/repo/bin/suckless/quark target: /var/services/dirlist/repo/bin/dirl
source: quark-dirl source:
- dirl-glibc-x86_64
- dirl-musl-x86_64
- name: publish-container
image: plugins/docker
settings:
username:
from_secret: docker_username
password:
from_secret: docker_password
dockerfile: Dockerfile
purge: true
repo: arminfriedl/dirl
tags: latest

9
Dockerfile Normal file
View file

@ -0,0 +1,9 @@
FROM alpine
RUN adduser web --disabled-password --no-create-home --shell /sbin/nologin && \
addgroup web web && \
mkdir -p /var/www/html
COPY dirl /usr/local/bin
ENTRYPOINT ["dirl", "-p", "80", "-u", "web", "-g", "web", "-n", "4096", "-h", "0.0.0.0", "-l", "-d", "/var/www/html"]

View file

@ -1,45 +1,25 @@
# See LICENSE file for copyright and license details # See LICENSE file for copyright and license details
# quark - simple web server # dirl - customizable directory listings based on quark
.POSIX: .POSIX:
include config.mk include config.mk
COMPONENTS = data http sock util dirl COMPONENTS = data http sock util dirl
all: quark all: dirl
data.o: data.c data.h util.h http.h dirl.h config.mk main.o: main.c util.h sock.h http.h arg.h config.h
dirl.o: dirl.c dirl.h util.h http.h config.mk http.o: http.c http.h util.h http.h data.h config.h
http.o: http.c http.h util.h http.h data.h config.h config.mk data.o: data.c data.h util.h http.h dirl.h
main.o: main.c util.h sock.h http.h arg.h config.h config.mk dirl.o: dirl.c dirl.h util.h http.h
sock.o: sock.c sock.h util.h config.mk sock.o: sock.c sock.h util.h
util.o: util.c util.h config.mk util.o: util.c util.h
quark: $(COMPONENTS:=.o) $(COMPONENTS:=.h) main.o config.mk dirl: $(COMPONENTS:=.o) $(COMPONENTS:=.h) main.o config.mk
$(CC) -o $@ $(CPPFLAGS) $(CFLAGS) $(COMPONENTS:=.o) main.o $(LDFLAGS) $(CC) -o $@ $(CPPFLAGS) $(CFLAGS) $(COMPONENTS:=.o) main.o $(LDFLAGS)
config.h: config.h:
cp config.def.h $@ cp config.def.h $@
clean: clean:
rm -f quark main.o $(COMPONENTS:=.o) rm -f dirl main.o $(COMPONENTS:=.o)
dist:
rm -rf "quark-$(VERSION)"
mkdir -p "quark-$(VERSION)"
cp -R LICENSE Makefile arg.h config.def.h config.mk quark.1 \
$(COMPONENTS:=.c) $(COMPONENTS:=.h) main.c "quark-$(VERSION)"
tar -cf - "quark-$(VERSION)" | gzip -c > "quark-$(VERSION).tar.gz"
rm -rf "quark-$(VERSION)"
install: all
mkdir -p "$(DESTDIR)$(PREFIX)/bin"
cp -f quark "$(DESTDIR)$(PREFIX)/bin"
chmod 755 "$(DESTDIR)$(PREFIX)/bin/quark"
mkdir -p "$(DESTDIR)$(MANPREFIX)/man1"
cp quark.1 "$(DESTDIR)$(MANPREFIX)/man1/quark.1"
chmod 644 "$(DESTDIR)$(MANPREFIX)/man1/quark.1"
uninstall:
rm -f "$(DESTDIR)$(PREFIX)/bin/quark"
rm -f "$(DESTDIR)$(MANPREFIX)/man1/quark.1"

View file

@ -1,15 +1,20 @@
[![Build Status](https://drone.friedl.net/api/badges/playground/suckless-quark/status.svg)](https://drone.friedl.net/playground/suckless-quark) [![Build Status](https://drone.friedl.net/api/badges/incubator/dirl/status.svg)](https://drone.friedl.net/incubator/dirl)
This is my private tree of [quark](tools.suckless.org/quark/). Upstream can be Dirl is a tiny server for customized directory listings. It is based on
found at https://git.suckless.org/quark. [quark](tools.suckless.org/quark/).
Quark is a small http server. # Getting Started
Pre-built binaries linked against glibc and musl can be downloaded from
[https://dirlist.friedl.net](https://dirlist.friedl.net/bin/dirl).
# DIRL In addition alpine based docker images are provided at
[DockerHub](https://hub.docker.com/repository/docker/arminfriedl/dirl).
dirl is a quark extension for customized directory listings. To start a directory listing just run the binary or start a container.
Per default dirl generates html for a directory listing like this: # Defaults
Per default dirl generates standard compliant html for a directory listing like
this:
```html ```html
<!DOCTYPE HTML PUBLIC " - // W3C//DTD HTML 3.2 Final//EN"> <!DOCTYPE HTML PUBLIC " - // W3C//DTD HTML 3.2 Final//EN">
@ -47,7 +52,7 @@ Per default dirl generates html for a directory listing like this:
<!-- /Footer Section --> <!-- /Footer Section -->
``` ```
## Customize # Customization
The default listing can be styled by a `style.css` in the root directory. The default listing can be styled by a `style.css` in the root directory.
@ -69,7 +74,7 @@ For each of these templates you can use placeholders that are replaced by their
* `{modified}`: Date the entry was last modified * `{modified}`: Date the entry was last modified
* `{size}`: Size of the entry (if available) * `{size}`: Size of the entry (if available)
### Subdirectory styling ## Subdirectory styling
dirl tries to the closest template for the currently visited path. This gives dirl tries to the closest template for the currently visited path. This gives
you the opportunity to override templates in subdirectories. dirl walks the you the opportunity to override templates in subdirectories. dirl walks the
@ -80,7 +85,7 @@ templates in that directory.
In case no templates are found up until and including root, the default In case no templates are found up until and including root, the default
templates are used. templates are used.
### Customize names ## Customize names
The files defined as templates and style are ignored in the directory listing The files defined as templates and style are ignored in the directory listing
itself. In case you need to list one of these directories, or have any other itself. In case you need to list one of these directories, or have any other

View file

@ -1,4 +1,4 @@
# quark version # dirl version
VERSION = 0 VERSION = 0
# Customize below to fit your system # Customize below to fit your system
@ -9,7 +9,7 @@ MANPREFIX = $(PREFIX)/share/man
# flags # flags
CPPFLAGS = -DVERSION=\"$(VERSION)\" -D_DEFAULT_SOURCE -D_XOPEN_SOURCE=700 -D_BSD_SOURCE CPPFLAGS = -DVERSION=\"$(VERSION)\" -D_DEFAULT_SOURCE -D_XOPEN_SOURCE=700 -D_BSD_SOURCE
CFLAGS = -std=c99 -pedantic -Wall -Wextra -Os CFLAGS = -std=c99 -pedantic -Wall -Wextra -Os $(STATIC)
LDFLAGS = -s LDFLAGS = -s
# compiler and linker # compiler and linker

BIN
dirl Executable file

Binary file not shown.

131
quark.1
View file

@ -1,131 +0,0 @@
.Dd 2020-08-23
.Dt QUARK 1
.Os suckless.org
.Sh NAME
.Nm quark
.Nd simple static web server
.Sh SYNOPSIS
.Nm
.Fl p Ar port
.Op Fl h Ar host
.Op Fl u Ar user
.Op Fl g Ar group
.Op Fl n Ar num
.Op Fl d Ar dir
.Op Fl l
.Op Fl i Ar file
.Oo Fl v Ar vhost Oc ...
.Oo Fl m Ar map Oc ...
.Nm
.Fl U Ar file
.Op Fl p Ar port
.Op Fl u Ar user
.Op Fl g Ar group
.Op Fl n Ar num
.Op Fl d Ar dir
.Op Fl l
.Op Fl i Ar file
.Oo Fl v Ar vhost Oc ...
.Oo Fl m Ar map Oc ...
.Sh DESCRIPTION
.Nm
is a simple HTTP GET/HEAD-only web server for static content.
It supports virtual hosts (see
.Fl v ) ,
explicit redirects (see
.Fl m ) ,
directory listings (see
.Fl l ) ,
conditional "If-Modified-Since"-requests (RFC 7232), range requests
(RFC 7233) and well-known URIs (RFC 8615), while refusing to serve
hidden files and directories.
.Sh OPTIONS
.Bl -tag -width Ds
.It Fl d Ar dir
Serve
.Ar dir
after chrooting into it.
The default is ".".
.It Fl g Ar group
Set group ID when dropping privileges, and in socket mode the group of the
socket file, to the ID of
.Ar group .
The default is "nogroup".
.It Fl h Ar host
Use
.Ar host
as the server hostname.
The default is the loopback interface (i.e. localhost).
.It Fl i Ar file
Set
.Ar file
as the directory index.
The default is "index.html".
.It Fl l
Enable directory listing.
.It Fl m Ar map
Add the URI prefix mapping rule specified by
.Ar map ,
which has the form
.Qq Pa from to [chost] ,
where each element is separated with spaces (0x20) that can be
escaped with '\\'.
.Pp
The prefix
.Pa from
of all matching URIs is replaced with
.Pa to ,
optionally limited to the canonical virtual host
.Pa chost .
If no virtual hosts are given,
.Pa chost
is ignored.
.It Fl n Ar num
Set the maximum number of threads to
.Ar num .
The default is 512.
.It Fl p Ar port
In host mode, listen on port
.Ar port
for incoming connections.
In socket mode, use
.Ar port
for constructing proper virtual host
redirects on non-standard ports.
.It Fl U Ar file
Create the UNIX-domain socket
.Ar file ,
listen on it for incoming connections and remove it on exit.
.It Fl u Ar user
Set user ID when dropping privileges,
and in socket mode the user of the socket file,
to the ID of
.Ar user .
The default is "nobody".
.It Fl v Ar vhost
Add the virtual host specified by
.Ar vhost ,
which has the form
.Qq Pa chost regex dir [prefix] ,
where each element is separated with spaces (0x20) that can be
escaped with '\\'.
.Pp
A request matching the virtual host regular expression
.Pa regex
(see
.Xr regex 3 )
is redirected to the canonical host
.Pa chost ,
if they differ, using the directory
.Pa dir
as the root directory, optionally prefixing the URI with
.Pa prefix .
If any virtual hosts are specified, all requests on non-matching
hosts are discarded.
.El
.Sh CUSTOMIZATION
.Nm
can be customized by creating a custom config.h from config.def.h and
(re)compiling the source code. This keeps it fast, secure and simple.
.Sh AUTHORS
.An Laslo Hunhold Aq Mt dev@frign.de