aboutsummaryrefslogtreecommitdiffstats
path: root/test/cgi.sh
blob: ba41998264c675e7c59515298f72894ebd21ce99 (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
#!/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"
while [ $# -ge 1 ]; do
    case "$1" in
        --release|-r)
            release="release"
            ;;
        *)
            die "Invalid option: $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=/
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