forked from cptjhmiller/omv-zoneminder
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathzms-inetd.conf
53 lines (51 loc) · 1.42 KB
/
zms-inetd.conf
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
#!/bin/bash
#
# Inetd-wrapper for ZMS (Zoneminder Streaming Server)
#
# Version: 2007-09-27
# Author: Kurt Zankl <[email protected]>
# Inspiration: http://www.debian-administration.org/articles/371
# Requirements: bash, inetd
# License: GNU General Public License, Version 2
#
# /etc/services:
# zms-inetd 85/tcp # Zoneminder ZMS inetd-wrapper
#
# /etc/inetd.conf:
# zms-inetd stream tcp nowait www-data /usr/local/bin/zms-inetd zms-inetd
#
# ZM Options / Paths / Web path to zms streaming server:
# ZM_PATH_ZMS = http://<server>:85/<anypath>
#
# configuration
ZMCONF="/etc/zm/zm.conf"
CGIBIN="nph-zms"
# error handler
function errormsg {
echo "HTTP/1.0 500 Internal Server Error"
echo "Content-Type: text/html"
echo
echo "<title>ERROR</title><h1>ERROR</h1>"
echo -e "<pre>$1</""pre>"
exit 1
}
# get request
read REQUEST
# skip headers
HEADER="nothing"; while [ "$HEADER" != $'\r' -a -n "$HEADER" ]; do read HEADER; done
# read ZM configuration
[ -r $ZMCONF ] || errormsg "Error reading Zoneminder configuration \"$ZMCONF\""
. $ZMCONF
ZMS="$ZM_PATH_CGI/$CGIBIN"
[ -x $ZMS ] || errormsg "Error finding ZMS executable \"$ZMS\""
[ -z "$REQUEST" ] && errormsg "Request is empty"
URL="${REQUEST#GET }"
URL="${URL% HTTP/*}"
QUERY="${URL#*\?}"
URL="${URL%%\?*}"
[ "$QUERY" == "$URL" ] && errormsg "Invalid query you twat $QUERY - $URL"
export QUERY_STRING="$QUERY"
echo "HTTP/1.0 200 OK"
.$ZMS
echo
exit 0