aboutsummaryrefslogtreecommitdiffstats
path: root/test/cgi.sh
blob: 4b08260a649a19d57c329d900c42e4cbaff48006 (plain)
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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
#!/bin/sh
# -*- coding: utf-8 -*-

basedir="$(realpath "$0" | xargs dirname)"

info()
{
    echo "--- $*"
}

error()
{
    echo "=== ERROR: $*" >&2
}

warning()
{
    echo "=== WARNING: $*" >&2
}

die()
{
    error "$*"
    exit 1
}

release="debug"
get_path="/"
while [ $# -ge 1 ]; do
    case "$1" in
        --debug|-d)
            release="debug"
            ;;
        --release|-r)
            release="release"
            ;;
        *)
            get_path="$1"
            ;;
    esac
    shift
done

target="$basedir/../target/$release"
binary="$target/cms-cgi"
[ -x "$binary" ] || die "cms-cgi binary $binary not found."

rundir="$basedir/run"
export QUERY_STRING=
export REQUEST_METHOD=GET
export PATH_INFO="$get_path"
export CONTENT_LENGTH=
export CONTENT_TYPE=
export HTTPS=on
export HTTP_HOST=example.com
export HTTP_COOKIE=

"$binary" --rundir "$rundir" || die "cms-cgi failed."

# vim: ts=4 sw=4 expandtab
bues.ch cgit interface