diff options
author | Case Duckworth | 2023-05-25 00:15:01 -0500 |
---|---|---|
committer | Case Duckworth | 2023-05-25 00:15:01 -0500 |
commit | bf2677e0dc75ec0e822990d2b96c8639039a7f5d (patch) | |
tree | d7824e964476db8d93b854fe625b3fe0f8ac4245 | |
download | cacophony-bf2677e0dc75ec0e822990d2b96c8639039a7f5d.tar.gz cacophony-bf2677e0dc75ec0e822990d2b96c8639039a7f5d.zip |
Initial commit
-rwxr-xr-x | cacophony.sh | 36 | ||||
-rw-r--r-- | lighttpd.conf | 12 | ||||
-rw-r--r-- | makefile | 2 | ||||
-rw-r--r-- | readme | 7 | ||||
-rwxr-xr-x | source/index | 8 |
5 files changed, 65 insertions, 0 deletions
diff --git a/cacophony.sh b/cacophony.sh new file mode 100755 index 0000000..7cf4dc3 --- /dev/null +++ b/cacophony.sh | |||
@@ -0,0 +1,36 @@ | |||
1 | #!/bin/sh | ||
2 | |||
3 | SCRIPTDIR=source | ||
4 | |||
5 | crlf() { # crlf < INPUT | ||
6 | ## Convert LF to CRLF | ||
7 | sed 's/$/ /g' | ||
8 | } | ||
9 | |||
10 | header() { # header [STATUS] | ||
11 | cat <<HEADER | crlf | ||
12 | HTTP/1.1 ${1:-200} | ||
13 | Content-Type: text/html;charset=utf-8 | ||
14 | |||
15 | HEADER | ||
16 | } | ||
17 | |||
18 | hexec() { # hexec PROGRAM [header args] | ||
19 | prog="$1"; shift | ||
20 | header "$@" | ||
21 | exec "$prog" | ||
22 | } | ||
23 | |||
24 | run() { | ||
25 | if test / = "$PATH_INFO" | ||
26 | then PATH_INFO=/index run | ||
27 | else | ||
28 | path="$PWD/$SCRIPTDIR$PATH_INFO" | ||
29 | if ! test -d "$path" && test -x "$path" | ||
30 | then hexec "$path" 200 | ||
31 | else header 404 | ||
32 | fi | ||
33 | fi | ||
34 | } | ||
35 | |||
36 | run | ||
diff --git a/lighttpd.conf b/lighttpd.conf new file mode 100644 index 0000000..cfd14f2 --- /dev/null +++ b/lighttpd.conf | |||
@@ -0,0 +1,12 @@ | |||
1 | server.document-root = "/home/acdw/src/cacophony" | ||
2 | server.port = 3030 | ||
3 | server.username = "acdw" | ||
4 | server.groupname = "acdw" | ||
5 | |||
6 | index-file.names = ( "index.html", "cacophony.sh" ) | ||
7 | |||
8 | server.modules += ( "mod_cgi", "mod_rewrite" ) | ||
9 | cgi.assign = ( ".sh" => "" ) | ||
10 | url.rewrite-if-not-file = ( "" => "/cacophony.sh${url.path}${qsa}" ) | ||
11 | |||
12 | mimetype.assign += ( "" => "text/plain;charset=utf-8" ) \ No newline at end of file | ||
diff --git a/makefile b/makefile new file mode 100644 index 0000000..b783d07 --- /dev/null +++ b/makefile | |||
@@ -0,0 +1,2 @@ | |||
1 | serve: cacophony.sh lighttpd.conf | ||
2 | lighttpd -D -f lighttpd.conf | ||
diff --git a/readme b/readme new file mode 100644 index 0000000..45b6535 --- /dev/null +++ b/readme | |||
@@ -0,0 +1,7 @@ | |||
1 | CACOPHONY | ||
2 | "Every page a program" | ||
3 | |||
4 | This repo contains *cacophony.sh*, a CGI script that will run every script in | ||
5 | the source/ directory as a CGI script to display a page. | ||
6 | |||
7 | This is probably a bad idea. It originated mostly on tilde.town. \ No newline at end of file | ||
diff --git a/source/index b/source/index new file mode 100755 index 0000000..1b870b4 --- /dev/null +++ b/source/index | |||
@@ -0,0 +1,8 @@ | |||
1 | #!/bin/sh | ||
2 | # -*- markdown -*- | ||
3 | echo "<!DOCTYPE html>";pandoc <<EOF;echo "</body></html>" | ||
4 | |||
5 | # Every page a program | ||
6 | ## an exciting new experiment in web development | ||
7 | |||
8 | Er, not really, lol. This is a plain CGI script with shit tacked on. Anyway ... | ||