32 lines
1.7 KiB
Bash
Executable File
32 lines
1.7 KiB
Bash
Executable File
#!/bin/sh
|
|
# ONVIF Profile S: busybox httpd(CGI) + wsd_simple_server.
|
|
# Expects the built binaries + templates deployed in /data/onvif/ :
|
|
# /data/onvif/onvif_simple_server /data/onvif/wsd_simple_server
|
|
# /data/onvif/wsd_files/ (+ any *_service_files the build needs)
|
|
PATH=$PATH:/bin:/sbin:/usr/bin:/usr/sbin
|
|
OD=/data/onvif
|
|
WWW=$OD/www
|
|
PORT=8080
|
|
[ -x "$OD/onvif_simple_server" ] || { echo "onvif: build+copy binaries into $OD (see RTSP.md)"; exit 1; }
|
|
|
|
# /data/onvif.conf = written by camcfg (synced resolution + login); else the image default
|
|
if [ -f /data/onvif.conf ]; then cp -f /data/onvif.conf /etc/onvif_simple_server.conf
|
|
else cp -f /usr/local/onvif/onvif.conf /etc/onvif_simple_server.conf; fi
|
|
mkdir -p "$WWW/cgi-bin" /var/log
|
|
# the CGI chooses its service from argv0 -> one symlink per service
|
|
for s in device_service media_service media2_service imaging_service \
|
|
deviceio_service ptz_service events_service; do
|
|
ln -sf "$OD/onvif_simple_server" "$WWW/cgi-bin/$s"
|
|
done
|
|
|
|
# serve cgi-bin; busybox runs anything under /cgi-bin/ as CGI
|
|
# busybox on this rootfs has NO httpd applet -> ship one (e.g. static busybox with httpd)
|
|
HTTPD=$OD/httpd; [ -x "$HTTPD" ] || HTTPD=$(command -v httpd)
|
|
[ -n "$HTTPD" ] || { echo "onvif: no httpd - copy a static busybox httpd to $OD/httpd"; exit 1; }
|
|
"$HTTPD" -p "$PORT" -h "$WWW"
|
|
# WS-Discovery so NVRs/apps auto-find the camera (advertise the device service)
|
|
"$OD/wsd_simple_server" -x "http://%s:$PORT/cgi-bin/device_service" \
|
|
-p /var/run/wsd.pid -t "$OD/wsd_files" \
|
|
-m AK3918AV130 -n Anyka -s "onvif://www.onvif.org/Profile/Streaming" &
|
|
echo "onvif: http://<ip>:$PORT/cgi-bin/device_service (+WS-Discovery)"
|