#!/bin/sh ROOT=. PORT=80 AUTHFILE=/tmp/.htpasswd if [ -z "$SPAWNED" ] ; then export SPAWNED=yes spipe -g -d -l $PORT -e $0 # Run master server exit 0 fi cd $ROOT # Go to document root read METHOD URI PROTO # Read in the request [ "$URI" = "/" ] && URI=index.cgi # If / requested, give default URI="./$URI" EXT=${URI##*.} # File extention if [ $AUTHFILE ] && [ -z $Authorizaion ] ; then echo "HTTP/1.0 401 Unauthorized" echo echo "Authorization required" elif [ "$EXT" = cgi ] ; then echo "HTTP/1.0 200 OK" exec $URI elif [ -f "$URI" ] ; then case "$EXT" in gif) CT=image/gif ;; png) CT=image/png ;; jpg) CT=image/jpeg ;; css) CT=text/plain ;; *) CT=text/html ;; esac echo "HTTP/1.0 200 OK" echo "Conent-type: $CT" echo cat $URI else echo "HTTP/1.0 404 Not found" echo echo "$URI Not found" fi