forked from mainsail-crew/crowsnest
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathcrowsnest
executable file
·89 lines (79 loc) · 2 KB
/
crowsnest
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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
#!/bin/bash
#### Webcamd Core Application.
#### crowsnest - A webcam Service for multiple Cams and Stream Services.
####
#### Written by Stephan Wendel aka KwadFan <[email protected]>
#### Copyright 2021
#### https://github.com/mainsail-crew/crowsnest
####
#### This File is distributed under GPLv3
####
# shellcheck enable=require-variable-braces
# Exit upon Errors
set -Ee
# Base Path
BASE_CN_PATH="$(dirname "$(readlink -f "${0}")")"
## Import Librarys
# shellcheck source-path=SCRIPTDIR/../libs/
. "${BASE_CN_PATH}/libs/camera-streamer.sh"
. "${BASE_CN_PATH}/libs/configparser.sh"
. "${BASE_CN_PATH}/libs/core.sh"
. "${BASE_CN_PATH}/libs/hwhandler.sh"
. "${BASE_CN_PATH}/libs/init_stream.sh"
. "${BASE_CN_PATH}/libs/logging.sh"
. "${BASE_CN_PATH}/libs/messages.sh"
. "${BASE_CN_PATH}/libs/ustreamer.sh"
. "${BASE_CN_PATH}/libs/v4l2_control.sh"
. "${BASE_CN_PATH}/libs/versioncontrol.sh"
. "${BASE_CN_PATH}/libs/watchdog.sh"
#### MAIN
## Args given?
if [ "$#" -eq 0 ]; then
missing_args_msg
exit 1
fi
## Parse Args
while getopts ":vhc:s:d" arg; do
case "${arg}" in
v )
echo -e "\ncrowsnest Version: $(self_version)\n"
exit 0
;;
h )
help_msg
exit 0
;;
c )
check_cfg "${OPTARG}"
export CROWSNEST_CFG="${OPTARG}"
;;
s )
if [[ "$(awk '{print $1}' /proc/uptime | cut -d '.' -f 1)" -lt "120" ]]; then
if [[ "${OPTARG}" ]]; then
sleep "${OPTARG}"
else
sleep 5
fi
fi
;;
d )
set -x
;;
\?)
wrong_args_msg
exit 1
;;
esac
done
init_logging
initial_check
construct_streamer
## Loop and Watchdog
## In this case watchdog acts more like a "cable defect detector"
## The User gets a message if Device is lost.
clean_watchdog
while true ; do
crowsnest_watchdog
sleep 120 & sleep_pid="$!"
wait "${sleep_pid}"
done