File: server.sh

package info (click to toggle)
debci 0.10.3
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 904 kB
  • ctags: 310
  • sloc: sh: 1,662; ruby: 1,007; makefile: 35
file content (36 lines) | stat: -rwxr-xr-x 708 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#!/bin/sh

case $# in
  0)
    port=8888
    ;;
  1)
    port="$1"
    ;;
  *)
    echo "usage: $0 [PORT]"
    ;;
esac

document_root="$(dirname $0)/../public"

conffile=$(mktemp)
cleanup() {
  rm -rf "$conffile"
}
trap cleanup INT TERM EXIT

cat > "$conffile" <<-EOF
server.document-root = "$document_root"
server.port = $port
include_shell "/usr/share/lighttpd/create-mime.assign.pl"
mimetype.assign += (".log" => "text/plain; charset=utf-8")
dir-listing.encoding        = "utf-8"
server.dir-listing          = "enable"
index-file.names            = ("index.html", "index.htm")
EOF

echo "I: Go to: http://localhost:$port/"
echo "I: Hit Control+C to stop"
echo ""
exec /usr/sbin/lighttpd -f "$conffile" -D