]> git.pld-linux.org Git - packages/lighttpd.git/commitdiff
- autogenerator
authorElan Ruusamäe <glen@pld-linux.org>
Tue, 15 Nov 2005 13:45:16 +0000 (13:45 +0000)
committercvs2git <feedback@pld-linux.org>
Sun, 24 Jun 2012 12:13:13 +0000 (12:13 +0000)
Changed files:
    lighttpd-mime.types.sh -> 1.1

lighttpd-mime.types.sh [new file with mode: 0644]

diff --git a/lighttpd-mime.types.sh b/lighttpd-mime.types.sh
new file mode 100644 (file)
index 0000000..089dbd0
--- /dev/null
@@ -0,0 +1,41 @@
+#!/bin/sh
+# Parse /etc/mime.types into lighttpd config format.
+# Copyright (c) 2005 Elan Ruusamäe <glen@pld-linux.org>
+
+mimetypes="$1"
+
+# build mime.types from system mime.types
+# get ones with extension
+awk '!/^#/ && $2 { print } ' $mimetypes | \
+# lay out mime types with multiple extension as separate lines \
+awk '{for (a=2; a <= NF; a++) {printf("%s\t%s\n", $1, $a)}}' | \
+# sort it \
+LC_ALL=C sort -u > mime.types
+
+# build lighttpd.conf fragment
+awk '{ printf("\t\".%s\"%s=> \"%s\",\n", $2, (length($2) > 4 ? "\t" : "\t\t"), $1)}' \
+       < mime.types | LC_ALL=C sort -r > mime.types.conf
+
+# sanity check. there can't be more than one mime type mapping for same extension
+dup=$(awk -F'"' '{print $2}' mime.types.conf | sort | uniq -c | grep -v '1' | awk '{print $NF}')
+if [ "$dup" ]; then
+       echo >&2 Found $(echo "$dup" | wc -w) extensions which have non-unique mime-type mapping:
+       echo "$dup" | sed -e 's,^,  ,' >&2
+       exit 1
+fi
+
+mv -f mime.types.conf mime.types.conf.tmp
+
+# header
+cat >> mime.types.conf <<EOF
+# mimetype mapping
+mimetype.assign = (
+EOF
+
+# save our hard work
+cat mime.types.conf.tmp >> mime.types.conf
+
+# footer
+cat >> mime.types.conf <<EOF
+)
+EOF
This page took 0.053771 seconds and 4 git commands to generate.