summaryrefslogtreecommitdiffstats
path: root/bin/test-web-server
blob: 708f80d9c59c776c20118f8b8ed5ecd638b97183 (plain) (blame)
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
#!/bin/bash

set -e

server_port=10605
service=tracker_service.py
thttpd=/usr/sbin/thttpd

if ! command -v mktemp > /dev/null ; then
    echo 'error: mktemp required'
    exit 1
elif ! command -v servinvoke > /dev/null ; then
    echo 'error: servinvoke required'
    exit 1
elif ! test -x $thttpd ; then
    echo 'error: thttpd required'
    exit 1
fi

bindir=`dirname $0`
if ! test -r "$bindir/$service" ; then
    echo "error: failed to locate bin directory (tried $bindir)"
    exit 1
fi

webroot=`mktemp -d`
if ! test -d $webroot ; then
    echo "error: invalid TMPDIR setting"
    rm -rf -- "$webroot"
    exit 1
fi
trap "rm -rf $webroot" 0
cat > $webroot/tracker <<EOF
#!/usr/bin/servinvoke

copy-env
target-unix $webroot/service-socket
EOF
chmod 755 $webroot/tracker
$thttpd -h localhost -p $server_port -c tracker \
    -d $webroot -l $webroot/log -i $webroot/pid
echo "URL: http://localhost:$server_port/tracker"

cd "$bindir"
python $service $webroot/service-socket ../data/security.db || true
read pid < $webroot/pid
kill "$pid"

© 2014-2024 Faster IT GmbH | imprint | privacy policy