refactor!: renaming webcamd to crowsnest

BREAKING CHANGE: This will require a reinstall of crowsnest

Signed-off-by: Stephan Wendel <me@stephanwe.de>
This commit is contained in:
Stephan Wendel
2022-06-12 11:54:32 +02:00
parent 11172878eb
commit 104536cd21
27 changed files with 173 additions and 143 deletions

View File

@@ -1,4 +1,4 @@
#### webcamd - A webcam Service for multiple Cams and Stream Services. #### crowsnest - A webcam Service for multiple Cams and Stream Services.
#### ####
#### Written by Stephan Wendel aka KwadFan <me@stephanwe.de> #### Written by Stephan Wendel aka KwadFan <me@stephanwe.de>
#### Copyright 2021 #### Copyright 2021

View File

@@ -2,7 +2,7 @@
#### Webcamd Core Application. #### Webcamd Core Application.
#### webcamd - A webcam Service for multiple Cams and Stream Services. #### crowsnest - A webcam Service for multiple Cams and Stream Services.
#### ####
#### Written by Stephan Wendel aka KwadFan <me@stephanwe.de> #### Written by Stephan Wendel aka KwadFan <me@stephanwe.de>
#### Copyright 2021 #### Copyright 2021
@@ -44,7 +44,7 @@ fi
while getopts ":vhc:" arg; do while getopts ":vhc:" arg; do
case "${arg}" in case "${arg}" in
v ) v )
echo -e "\nwebcamd Version: $(self_version)\n" echo -e "\ncrowsnest Version: $(self_version)\n"
exit 0 exit 0
;; ;;
h ) h )
@@ -53,7 +53,7 @@ while getopts ":vhc:" arg; do
;; ;;
c ) c )
check_cfg "${OPTARG}" check_cfg "${OPTARG}"
export WEBCAMD_CFG="${OPTARG}" export CROWSNEST_CFG="${OPTARG}"
;; ;;
\?) \?)
wrong_args_msg wrong_args_msg
@@ -73,7 +73,7 @@ brokenfocus
## The User gets a message if Device is lost. ## The User gets a message if Device is lost.
clean_watchdog clean_watchdog
while true ; do while true ; do
webcamd_watchdog crowsnest_watchdog
sleep 120 & sleep_pid="$!" sleep 120 & sleep_pid="$!"
wait "${sleep_pid}" wait "${sleep_pid}"
done done

View File

@@ -1,5 +1,5 @@
#!/bin/bash #!/bin/bash
#### webcamd - A webcam Service for multiple Cams and Stream Services. #### crowsnest - A webcam Service for multiple Cams and Stream Services.
#### ####
#### Written by Stephan Wendel aka KwadFan <me@stephanwe.de> #### Written by Stephan Wendel aka KwadFan <me@stephanwe.de>
#### Copyright 2021 #### Copyright 2021

View File

@@ -1,6 +1,6 @@
#!/usr/bin/env bash #!/usr/bin/env bash
#### webcamd - A webcam Service for multiple Cams and Stream Services. #### crowsnest - A webcam Service for multiple Cams and Stream Services.
#### ####
#### Written by Stephan Wendel aka KwadFan <me@stephanwe.de> #### Written by Stephan Wendel aka KwadFan <me@stephanwe.de>
#### Copyright 2021 #### Copyright 2021

View File

@@ -1,4 +1,4 @@
#### webcamd - A webcam Service for multiple Cams and Stream Services. #### crowsnest - A webcam Service for multiple Cams and Stream Services.
#### ####
#### Written by Stephan Wendel aka KwadFan <me@stephanwe.de> #### Written by Stephan Wendel aka KwadFan <me@stephanwe.de>
#### Copyright 2021 #### Copyright 2021

View File

@@ -1,4 +1,4 @@
#### webcamd - A webcam Service for multiple Cams and Stream Services. #### crowsnest - A webcam Service for multiple Cams and Stream Services.
#### ####
#### Written by Stephan Wendel aka KwadFan <me@stephanwe.de> #### Written by Stephan Wendel aka KwadFan <me@stephanwe.de>
#### Copyright 2021 #### Copyright 2021
@@ -8,7 +8,7 @@
#### ####
[Unit] [Unit]
Description=webcamd - Multi Webcam/Streamer Control Deamon Description=crowsnest - Multi Webcam/Streamer Control Deamon
Documentation=https://github.com/mainsail-crew/crowsnest Documentation=https://github.com/mainsail-crew/crowsnest
After=udev.service network-online.target nss-lookup.target After=udev.service network-online.target nss-lookup.target
Wants=udev.service network-online.target Wants=udev.service network-online.target
@@ -17,14 +17,13 @@ StartLimitBurst=10
StartLimitIntervalSec=180 StartLimitIntervalSec=180
[Install] [Install]
Alias=crowsnest
WantedBy=multi-user.target WantedBy=multi-user.target
[Service] [Service]
Environment=WEBCAMD_CONFIG=/home/pi/klipper_config/webcam.conf Environment=CROWSNEST_CONFIG=/home/pi/klipper_config/crowsnest.conf
Type=exec Type=exec
User=pi User=pi
RemainAfterExit=Yes RemainAfterExit=Yes
ExecStart= /usr/local/bin/webcamd -c ${WEBCAMD_CONFIG} ExecStart= /usr/local/bin/crowsnest -c ${CROWSNEST_CONFIG}
Restart=on-failure Restart=on-failure
RestartSec=5 RestartSec=5

View File

@@ -1,6 +1,6 @@
# webcamd logrotate file # crowsnest logrotate file
#### webcamd - A webcam Service for multiple Cams and Stream Services. #### crowsnest - A webcam Service for multiple Cams and Stream Services.
#### ####
#### Written by Stephan Wendel aka KwadFan <me@stephanwe.de> #### Written by Stephan Wendel aka KwadFan <me@stephanwe.de>
#### Copyright 2021 #### Copyright 2021
@@ -10,7 +10,7 @@
#### ####
/home/pi/klipper_logs/webcamd.log { /home/pi/klipper_logs/crowsnest.log {
rotate 3 rotate 3
missingok missingok
notifempty notifempty

View File

@@ -1,6 +1,7 @@
# Crowsnest update_manager entry # Crowsnest update_manager entry
[update_manager webcamd] [update_manager crowsnest]
type: git_repo type: git_repo
path: ~/crowsnest path: ~/crowsnest
origin: https://github.com/mainsail-crew/crowsnest.git origin: https://github.com/mainsail-crew/crowsnest.git
managed_services: crowsnest

View File

@@ -2,7 +2,7 @@
#### Configparser library #### Configparser library
#### webcamd - A webcam Service for multiple Cams and Stream Services. #### crowsnest - A webcam Service for multiple Cams and Stream Services.
#### ####
#### Written by Stephan Wendel aka KwadFan <me@stephanwe.de> #### Written by Stephan Wendel aka KwadFan <me@stephanwe.de>
#### Copyright 2021 #### Copyright 2021
@@ -21,7 +21,7 @@ set -Ee
# spits out raw value # spits out raw value
function get_param { function get_param {
local cfg section param local cfg section param
cfg="${WEBCAMD_CFG}" cfg="${CROWSNEST_CFG}"
section="${1}" section="${1}"
param="${2}" param="${2}"
crudini --get "${cfg}" "${section}" "${param}" 2> /dev/null | \ crudini --get "${cfg}" "${section}" "${param}" 2> /dev/null | \
@@ -40,9 +40,9 @@ function check_cfg {
## Spits out all [cam <nameornumber>] configured sections ## Spits out all [cam <nameornumber>] configured sections
function configured_cams { function configured_cams {
local cams cfg local cams cfg
cfg="${WEBCAMD_CFG}" cfg="${CROWSNEST_CFG}"
for i in $(crudini --existing=file --get "${cfg}" | \ for i in $(crudini --existing=file --get "${cfg}" | \
sed '/webcamd/d;s/cam//'); do sed '/crowsnest/d;s/cam//'); do
cams+=("${i}") cams+=("${i}")
done done
echo "${cams[@]}" echo "${cams[@]}"
@@ -54,7 +54,7 @@ function check_section {
local section exist param must_exist missing local section exist param must_exist missing
section="cam ${1}" section="cam ${1}"
# Ignore missing custom flags # Ignore missing custom flags
exist="$(crudini --existing=param --get "${WEBCAMD_CFG}" "${section}" \ exist="$(crudini --existing=param --get "${CROWSNEST_CFG}" "${section}" \
2> /dev/null | sed '/custom_flags/d;/v4l2ctl/d')" 2> /dev/null | sed '/custom_flags/d;/v4l2ctl/d')"
for i in ${exist}; do for i in ${exist}; do
param+=("${i}") param+=("${i}")

View File

@@ -2,7 +2,7 @@
#### Core library #### Core library
#### webcamd - A webcam Service for multiple Cams and Stream Services. #### crowsnest - A webcam Service for multiple Cams and Stream Services.
#### ####
#### Written by Stephan Wendel aka KwadFan <me@stephanwe.de> #### Written by Stephan Wendel aka KwadFan <me@stephanwe.de>
#### Copyright 2021 #### Copyright 2021
@@ -16,7 +16,7 @@
# Exit upon Errors # Exit upon Errors
set -Ee set -Ee
## Version of webcamd ## Version of crowsnest
function self_version { function self_version {
pushd "${BASE_CN_PATH}" &> /dev/null pushd "${BASE_CN_PATH}" &> /dev/null
git describe --always --tags git describe --always --tags
@@ -116,13 +116,13 @@ function initial_check {
check_apps check_apps
versioncontrol versioncontrol
# print cfg if ! log_level: quiet # print cfg if ! log_level: quiet
if [ -z "$(check_cfg "${WEBCAMD_CFG}")" ]; then if [ -z "$(check_cfg "${CROWSNEST_CFG}")" ]; then
if [ "$(log_level)" != "quiet" ]; then if [ "$(log_level)" != "quiet" ]; then
print_cfg print_cfg
fi fi
fi fi
# in systemd show always config file # in systemd show always config file
logger -t webcamd -f "${WEBCAMD_CFG}" logger -t crowsnest -f "${CROWSNEST_CFG}"
log_msg "INFO: Detect available Devices" log_msg "INFO: Detect available Devices"
print_cams print_cams
} }

View File

@@ -2,7 +2,7 @@
#### Hardware Handling library #### Hardware Handling library
#### webcamd - A webcam Service for multiple Cams and Stream Services. #### crowsnest - A webcam Service for multiple Cams and Stream Services.
#### ####
#### Written by Stephan Wendel aka KwadFan <me@stephanwe.de> #### Written by Stephan Wendel aka KwadFan <me@stephanwe.de>
#### Copyright 2021 #### Copyright 2021

View File

@@ -2,7 +2,7 @@
#### Init Stream library #### Init Stream library
#### webcamd - A webcam Service for multiple Cams and Stream Services. #### crowsnest - A webcam Service for multiple Cams and Stream Services.
#### ####
#### Written by Stephan Wendel aka KwadFan <me@stephanwe.de> #### Written by Stephan Wendel aka KwadFan <me@stephanwe.de>
#### Copyright 2021 #### Copyright 2021

View File

@@ -2,7 +2,7 @@
#### Logging library #### Logging library
#### webcamd - A webcam Service for multiple Cams and Stream Services. #### crowsnest - A webcam Service for multiple Cams and Stream Services.
#### ####
#### Written by Stephan Wendel aka KwadFan <me@stephanwe.de> #### Written by Stephan Wendel aka KwadFan <me@stephanwe.de>
#### Copyright 2021 #### Copyright 2021
@@ -19,7 +19,7 @@ set -Ee
## Logging ## Logging
function set_log_path { function set_log_path {
#Workaround sed ~ to BASH VAR $HOME #Workaround sed ~ to BASH VAR $HOME
CROWSNEST_LOG_PATH=$(get_param webcamd log_path | sed "s#^~#${HOME}#gi") CROWSNEST_LOG_PATH=$(get_param "crowsnest" log_path | sed "s#^~#${HOME}#gi")
declare -g CROWSNEST_LOG_PATH declare -g CROWSNEST_LOG_PATH
#Workaround: Make Dir if not exist #Workaround: Make Dir if not exist
if [ ! -d "$(dirname "${CROWSNEST_LOG_PATH}")" ]; then if [ ! -d "$(dirname "${CROWSNEST_LOG_PATH}")" ]; then
@@ -30,14 +30,14 @@ function set_log_path {
function init_logging { function init_logging {
set_log_path set_log_path
delete_log delete_log
log_msg "webcamd - A webcam Service for multiple Cams and Stream Services." log_msg "crowsnest - A webcam Service for multiple Cams and Stream Services."
log_msg "Version: $(self_version)" log_msg "Version: $(self_version)"
log_msg "Prepare Startup ..." log_msg "Prepare Startup ..."
} }
function log_level { function log_level {
local loglevel local loglevel
loglevel="$(get_param webcamd log_level 2> /dev/null)" loglevel="$(get_param crowsnest log_level 2> /dev/null)"
# Set default log_level to quiet # Set default log_level to quiet
if [ -z "${loglevel}" ] || [[ "${loglevel}" != @(quiet|verbose|debug) ]]; if [ -z "${loglevel}" ] || [[ "${loglevel}" != @(quiet|verbose|debug) ]];
then then
@@ -49,7 +49,7 @@ function log_level {
function delete_log { function delete_log {
local del_log local del_log
del_log="$(get_param "webcamd" delete_log 2> /dev/null)" del_log="$(get_param "crowsnest" delete_log 2> /dev/null)"
if [ "${del_log}" = "true" ]; then if [ "${del_log}" = "true" ]; then
rm -rf "${CROWSNEST_LOG_PATH}" rm -rf "${CROWSNEST_LOG_PATH}"
fi fi
@@ -58,9 +58,9 @@ function delete_log {
function log_msg { function log_msg {
local msg prefix local msg prefix
msg="${1}" msg="${1}"
prefix="$(date +'[%D %T]') webcamd:" prefix="$(date +'[%D %T]') crowsnest:"
echo -e "${prefix} ${msg}" | tr -s ' ' >> "${CROWSNEST_LOG_PATH}" 2>&1 echo -e "${prefix} ${msg}" | tr -s ' ' | tee -a "${CROWSNEST_LOG_PATH}" 2>&1
echo -e "${msg}" | logger -t webcamd echo -e "${msg}" | logger -t crowsnest
} }
#call '| log_output "<prefix>"' #call '| log_output "<prefix>"'
@@ -73,7 +73,7 @@ function log_output {
fi fi
if [ -n "${line}" ]; then if [ -n "${line}" ]; then
# needed to prettify ustreamers output # needed to prettify ustreamers output
echo "${line//^--/ustreamer}" | logger -t webcamd echo "${line//^--/ustreamer}" | logger -t crowsnest
fi fi
done done
} }
@@ -81,10 +81,10 @@ function log_output {
function print_cfg { function print_cfg {
local prefix local prefix
prefix="\t\t" prefix="\t\t"
log_msg "INFO: Print Configfile: '${WEBCAMD_CFG}'" log_msg "INFO: Print Configfile: '${CROWSNEST_CFG}'"
while read -r line; do while read -r line; do
log_msg "${prefix}${line}" log_msg "${prefix}${line}"
done < "${WEBCAMD_CFG}" done < "${CROWSNEST_CFG}"
} }
function print_cams { function print_cams {
@@ -120,6 +120,6 @@ function debug_msg {
prefix="Develop -- DEBUG:" prefix="Develop -- DEBUG:"
while read -r msg; do while read -r msg; do
log_msg "${prefix} ${msg}" log_msg "${prefix} ${msg}"
echo -e "${msg}" | logger -t webcamd echo -e "${msg}" | logger -t crowsnest
done <<< "${1}" done <<< "${1}"
} }

View File

@@ -2,7 +2,7 @@
#### message library #### message library
#### webcamd - A webcam Service for multiple Cams and Stream Services. #### crowsnest - A webcam Service for multiple Cams and Stream Services.
#### ####
#### Written by Stephan Wendel aka KwadFan <me@stephanwe.de> #### Written by Stephan Wendel aka KwadFan <me@stephanwe.de>
#### Copyright 2021 #### Copyright 2021
@@ -20,20 +20,20 @@ set -Ee
## core lib ## core lib
function missing_args_msg { function missing_args_msg {
echo -e "webcamd: Missing Arguments!" echo -e "crowsnest: Missing Arguments!"
echo -e "\n\tTry: webcamd -h\n" echo -e "\n\tTry: crowsnest -h\n"
} }
function wrong_args_msg { function wrong_args_msg {
echo -e "webcamd: Wrong Arguments!" echo -e "crowsnest: Wrong Arguments!"
echo -e "\n\tTry: webcamd -h\n" echo -e "\n\tTry: crowsnest -h\n"
} }
function help_msg { function help_msg {
echo -e "webcamd - webcam deamon\nUsage:" echo -e "crowsnest - webcam deamon\nUsage:"
echo -e "\t webcamd [Options]" echo -e "\t crowsnest [Options]"
echo -e "\n\t\t-h Prints this help." echo -e "\n\t\t-h Prints this help."
echo -e "\n\t\t-v Prints Version of webcamd." echo -e "\n\t\t-v Prints Version of crowsnest."
echo -e "\n\t\t-c </path/to/configfile>\n\t\t\tPath to your webcam.conf\n" echo -e "\n\t\t-c </path/to/configfile>\n\t\t\tPath to your webcam.conf\n"
} }

View File

@@ -2,7 +2,7 @@
#### ustreamer library #### ustreamer library
#### webcamd - A webcam Service for multiple Cams and Stream Services. #### crowsnest - A webcam Service for multiple Cams and Stream Services.
#### ####
#### Written by Stephan Wendel aka KwadFan <me@stephanwe.de> #### Written by Stephan Wendel aka KwadFan <me@stephanwe.de>
#### Copyright 2021 #### Copyright 2021

View File

@@ -2,7 +2,7 @@
#### ustreamer library #### ustreamer library
#### webcamd - A webcam Service for multiple Cams and Stream Services. #### crowsnest - A webcam Service for multiple Cams and Stream Services.
#### ####
#### Written by Stephan Wendel aka KwadFan <me@stephanwe.de> #### Written by Stephan Wendel aka KwadFan <me@stephanwe.de>
#### Copyright 2021 #### Copyright 2021

View File

@@ -2,7 +2,7 @@
#### v4l2 control library #### v4l2 control library
#### webcamd - A webcam Service for multiple Cams and Stream Services. #### crowsnest - A webcam Service for multiple Cams and Stream Services.
#### ####
#### Written by Stephan Wendel aka KwadFan <me@stephanwe.de> #### Written by Stephan Wendel aka KwadFan <me@stephanwe.de>
#### Copyright 2021 #### Copyright 2021

View File

@@ -2,7 +2,7 @@
#### version control library #### version control library
#### webcamd - A webcam Service for multiple Cams and Stream Services. #### crowsnest - A webcam Service for multiple Cams and Stream Services.
#### ####
#### Written by Stephan Wendel aka KwadFan <me@stephanwe.de> #### Written by Stephan Wendel aka KwadFan <me@stephanwe.de>
#### Copyright 2021 #### Copyright 2021

View File

@@ -2,7 +2,7 @@
#### Watchdog #### Watchdog
#### webcamd - A webcam Service for multiple Cams and Stream Services. #### crowsnest - A webcam Service for multiple Cams and Stream Services.
#### ####
#### Written by Stephan Wendel aka KwadFan <me@stephanwe.de> #### Written by Stephan Wendel aka KwadFan <me@stephanwe.de>
#### Copyright 2021 #### Copyright 2021
@@ -24,7 +24,7 @@ function clean_watchdog {
rm -f /tmp/lost-* rm -f /tmp/lost-*
} }
function webcamd_watchdog { function crowsnest_watchdog {
# Helper Functions # Helper Functions
function available { function available {
find "${1}" &> /dev/null find "${1}" &> /dev/null
@@ -52,8 +52,8 @@ function webcamd_watchdog {
function get_conf_devices { function get_conf_devices {
local gcd local gcd
for i in $(crudini --existing=file --get "${WEBCAMD_CFG}" | \ for i in $(crudini --existing=file --get "${CROWSNEST_CFG}" | \
sed '/webcamd/d' | cut -d ' ' -f2); do sed '/crowsnest/d' | cut -d ' ' -f2); do
gcd+=("${i}") gcd+=("${i}")
done done
echo "${gcd[@]}" echo "${gcd[@]}"
@@ -62,7 +62,7 @@ function webcamd_watchdog {
### MAIN ### MAIN
for i in $(get_conf_devices); do for i in $(get_conf_devices); do
cc="$(crudini --get "${WEBCAMD_CFG}" "cam ${i}" "device" \ cc="$(crudini --get "${CROWSNEST_CFG}" "cam ${i}" "device" \
| awk '{print $1}')" | awk '{print $1}')"
if [ "$(available "${cc}")" -ne 0 ] && [ "$(is_lost "${cc}")" -ne 0 ]; then if [ "$(available "${cc}")" -ne 0 ] && [ "$(is_lost "${cc}")" -ne 0 ]; then
log_msg "WATCHDOG: Lost Device: '${cc}'" log_msg "WATCHDOG: Lost Device: '${cc}'"

View File

@@ -1,16 +1,34 @@
### webcam.conf #### crowsnest.conf
### This is mainsail / MainsailOS default config. #### This is mainsail / MainsailOS default config.
### See docs.mainsail.xyz/whatever for Details to configure to your needs. #### See:
#### https://github.com/mainsail-crew/crowsnest/blob/master/README.md
#### for details to configure to your needs.
[webcamd] #####################################################################
log_path: ~/klipper_logs/webcamd.log # Default logfile in ~/klipper_logs/webcamd.log #### #####
#### Information about ports and according URL's #####
#### #####
#####################################################################
#### #####
#### Port 8080 equals /webcam/?action=[stream/snapshot] #####
#### Port 8081 equals /webcam2/?action=[stream/snapshot] #####
#### Port 8082 equals /webcam3/?action=[stream/snapshot] #####
#### Port 8083 equals /webcam4/?action=[stream/snapshot] #####
#### #####
#####################################################################
[crowsnest]
log_path: ~/klipper_logs/crowsnest.log # Default logfile in ~/klipper_logs/crowsnest.log
log_level: verbose # Valid Options are quiet/verbose/debug log_level: verbose # Valid Options are quiet/verbose/debug
delete_log: false # Deletes log on every restart, if set to true
[cam 1] [cam 1]
mode: mjpg # mjpg/rtsp/webrtc mode: mjpg # mjpg/rtsp
port: 8080 # Port port: 8080 # Port
device: /dev/video0 # See Log for available ... device: /dev/video0 # See Log for available ...
resolution: 640x480 # widthxheight format resolution: 640x480 # widthxheight format
max_fps: 15 # If Hardware Supports this it will be forced, ohterwise ignored/coerced. max_fps: 15 # If Hardware Supports this it will be forced, ohterwise ignored/coerced.
#custom_flags: # You can run the Stream Services with custom flags. #custom_flags: # You can run the Stream Services with custom flags.
#v4l2ctl: # Add v4l2-ctl parameters to setup your camera, see Log what your cam is capable of.

View File

@@ -1,15 +1,27 @@
[webcamd]
log_path: ~/klipper_logs/webcamd.log # Default logfile in ~/klipper_logs/webcamd.log
#####################################################################
#### #####
#### Information about ports and according URL's #####
#### #####
#####################################################################
#### #####
#### Port 8080 equals /webcam/?action=[stream/snapshot] #####
#### Port 8081 equals /webcam2/?action=[stream/snapshot] #####
#### Port 8082 equals /webcam3/?action=[stream/snapshot] #####
#### Port 8083 equals /webcam4/?action=[stream/snapshot] #####
#### #####
#####################################################################
[crowsnest]
log_path: ~/klipper_logs/crowsnest.log # Default logfile in ~/klipper_logs/crowsnest.log
log_level: quiet # Valid Options are quiet/verbose/debug log_level: quiet # Valid Options are quiet/verbose/debug
delete_log: false # true to get fresh log on every start delete_log: true # Deletes log on every restart, if set to true
[cam 1] [cam 1]
mode: mjpg # mjpg/rtsp/webrtc ( webrtc is comming in the future ) mode: mjpg # mjpg/rtsp
port: 8080 # Port for ustreamer port: 8080 # Port
device: /dev/video0 # See Log for available ... device: /dev/video0 # See Log for available ...
resolution: 640x480 # WidthxHeight format resolution: 640x480 # widthxheight format
max_fps: 15 # If Hardware Supports this it will be forced, ohterwise ignored/coerced. max_fps: 15 # If Hardware Supports this it will be forced, ohterwise ignored/coerced.
#custom_flags: # Custom Flags to set for ustreamer, this is optional

View File

@@ -1,5 +1,5 @@
#!/bin/bash #!/bin/bash
#### webcamd - A webcam Service for multiple Cams and Stream Services. #### crowsnest - A webcam Service for multiple Cams and Stream Services.
#### ####
#### Written by Stephan Wendel aka KwadFan <me@stephanwe.de> #### Written by Stephan Wendel aka KwadFan <me@stephanwe.de>
#### Copyright 2021 #### Copyright 2021

View File

@@ -1,5 +1,5 @@
#!/bin/bash #!/bin/bash
#### webcamd - A webcam Service for multiple Cams and Stream Services. #### crowsnest - A webcam Service for multiple Cams and Stream Services.
#### ####
#### Written by Stephan Wendel aka KwadFan <me@stephanwe.de> #### Written by Stephan Wendel aka KwadFan <me@stephanwe.de>
#### Copyright 2021 #### Copyright 2021

View File

@@ -1,5 +1,5 @@
#!/bin/bash #!/bin/bash
#### webcamd - A webcam Service for multiple Cams and Stream Services. #### crowsnest - A webcam Service for multiple Cams and Stream Services.
#### ####
#### Written by Stephan Wendel aka KwadFan <me@stephanwe.de> #### Written by Stephan Wendel aka KwadFan <me@stephanwe.de>
#### Copyright 2021 #### Copyright 2021

View File

@@ -1,5 +1,5 @@
#!/bin/bash #!/bin/bash
#### webcamd - A webcam Service for multiple Cams and Stream Services. #### crowsnest - A webcam Service for multiple Cams and Stream Services.
#### ####
#### Written by Stephan Wendel aka KwadFan <me@stephanwe.de> #### Written by Stephan Wendel aka KwadFan <me@stephanwe.de>
#### Copyright 2021 #### Copyright 2021

View File

@@ -40,7 +40,7 @@ function welcome_msg {
} }
function detect_msg { function detect_msg {
echo -e "Found an existing 'webcamd'. This will be removed." echo -e "Found an existing 'crowsnest'. This will be removed."
echo -e "Since we dont use mjpg-streamer it will also removed." echo -e "Since we dont use mjpg-streamer it will also removed."
echo -e "You can use KIAUH for example to reinstall.\n" echo -e "You can use KIAUH for example to reinstall.\n"
} }
@@ -128,17 +128,17 @@ function import_config {
fi fi
} }
### Detect webcamd. ### Detect crowsnest.
function detect_existing_webcamd { function detect_existing_crowsnest {
local remove local remove
if [ -x "/usr/local/bin/webcamd" ] && [ -d "${HOME}/mjpg-streamer" ]; then if [ -x "/usr/local/bin/crowsnest" ] && [ -d "${HOME}/mjpg-streamer" ]; then
detect_msg detect_msg
read -rp "Do you want to remove existing 'webcamd'? (YES/NO) " remove read -rp "Do you want to remove existing 'crowsnest'? (YES/NO) " remove
if [ "${remove}" = "YES" ]; then if [ "${remove}" = "YES" ]; then
echo -en "\nStopping webcamd.service ...\r" echo -en "\nStopping crowsnest.service ...\r"
sudo systemctl stop webcamd.service &> /dev/null sudo systemctl stop crowsnest.service &> /dev/null
echo -e "Stopping webcamd.service ... \t[OK]\r" echo -e "Stopping crowsnest.service ... \t[OK]\r"
remove_existing_webcamd remove_existing_crowsnest
else else
echo -e "\nYou answered '${remove}'! Installation will be aborted..." echo -e "\nYou answered '${remove}'! Installation will be aborted..."
echo -e "GoodBye...\n" echo -e "GoodBye...\n"
@@ -147,47 +147,47 @@ function detect_existing_webcamd {
fi fi
} }
### Remove existing webcamd ### Remove existing crowsnest
function remove_existing_webcamd { function remove_existing_crowsnest {
if [ -x "/usr/local/bin/webcamd" ]; then if [ -x "/usr/local/bin/crowsnest" ]; then
echo -en "Removing 'webcamd' ...\r" echo -en "Removing 'crowsnest' ...\r"
sudo rm -f /usr/local/bin/webcamd > /dev/null sudo rm -f /usr/local/bin/crowsnest > /dev/null
echo -e "Removing 'webcamd' ... \t\t[OK]\r" echo -e "Removing 'crowsnest' ... \t\t[OK]\r"
fi fi
if [ -d "${HOME}/mjpg-streamer" ]; then if [ -d "${HOME}/mjpg-streamer" ]; then
echo -en "Removing 'mjpg-streamer' ...\r" echo -en "Removing 'mjpg-streamer' ...\r"
sudo rm -rf "${HOME}"/mjpg-streamer > /dev/null sudo rm -rf "${HOME}"/mjpg-streamer > /dev/null
echo -e "Removing 'mjpg-streamer' ... \t[OK]\r" echo -e "Removing 'mjpg-streamer' ... \t[OK]\r"
fi fi
if [ -f "/etc/systemd/system/webcamd.service" ]; then if [ -f "/etc/systemd/system/crowsnest.service" ]; then
echo -en "Removing 'webcamd.service' ...\r" echo -en "Removing 'crowsnest.service' ...\r"
sudo rm -f /etc/systemd/system/webcamd.service > /dev/null sudo rm -f /etc/systemd/system/crowsnest.service > /dev/null
echo -e "Removing 'webcamd.service' ... \t[OK]\r" echo -e "Removing 'crowsnest.service' ... \t[OK]\r"
fi fi
if [ -f "/var/log/webcamd.log" ]; then if [ -f "/var/log/crowsnest.log" ]; then
echo -en "Removing 'webcamd.log' ...\r" echo -en "Removing 'crowsnest.log' ...\r"
sudo rm -f /var/log/webcamd.log > /dev/null sudo rm -f /var/log/crowsnest.log > /dev/null
sudo rm -f "${HOME}"/klipper_logs/webcamd.log > /dev/null sudo rm -f "${HOME}"/klipper_logs/crowsnest.log > /dev/null
echo -e "Removing 'webcamd.log' ... \t[OK]\r" echo -e "Removing 'crowsnest.log' ... \t[OK]\r"
fi fi
if [ -f "/etc/logrotate.d/webcamd" ]; then if [ -f "/etc/logrotate.d/crowsnest" ]; then
echo -en "Removing 'webcamd' logrotate...\r" echo -en "Removing 'crowsnest' logrotate...\r"
sudo rm -f /etc/logrotate.d/webcamd > /dev/null sudo rm -f /etc/logrotate.d/crowsnest > /dev/null
echo -e "Removing 'webcamd' logrotate ... \t[OK]\r" echo -e "Removing 'crowsnest' logrotate ... \t[OK]\r"
fi fi
echo -e "\nOld 'webcamd' completly removed." echo -e "\nOld 'crowsnest' completly removed."
echo -e "webcam.txt kept,but no longer necessary ..." echo -e "webcam.txt kept,but no longer necessary ..."
} }
function install_crowsnest { function install_crowsnest {
local addconf bin_path logrotatefile moonraker_conf moonraker_update local addconf bin_path logrotatefile moonraker_conf moonraker_update
local webcamd_bin servicefile template local crowsnest_bin servicefile template
bin_path="/usr/local/bin" bin_path="/usr/local/bin"
webcamd_bin="${HOME}/crowsnest/webcamd" crowsnest_bin="${HOME}/crowsnest/crowsnest"
template="${PWD}/sample_configs/${CROWSNEST_DEFAULT_CONF}" template="${PWD}/sample_configs/${CROWSNEST_DEFAULT_CONF}"
servicefile="${PWD}/file_templates/webcamd.service" servicefile="${PWD}/file_templates/crowsnest.service"
logrotatefile="${HOME}/crowsnest/file_templates/logrotate_webcamd" logrotatefile="${HOME}/crowsnest/file_templates/logrotate_crowsnest"
moonraker_conf="${HOME}/klipper_config/moonraker.conf" moonraker_conf="${HOME}/klipper_config/moonraker.conf"
moonraker_update="${PWD}/file_templates/moonraker_update.txt" moonraker_update="${PWD}/file_templates/moonraker_update.txt"
## helper func moonraker update_manager ## helper func moonraker update_manager
@@ -205,39 +205,39 @@ function install_crowsnest {
echo -e "moonraker.conf is missing ... [SKIPPED]" echo -e "moonraker.conf is missing ... [SKIPPED]"
fi fi
} }
echo -e "\nInstall webcamd Service ..." echo -e "\nInstall crowsnest Service ..."
## Install Dependencies ## Install Dependencies
echo -e "Installing 'crowsnest' Dependencies ..." echo -e "Installing 'crowsnest' Dependencies ..."
# shellcheck disable=2086 # shellcheck disable=2086
sudo apt install --yes --no-install-recommends ${CROWSNEST_CROWSNEST_DEPS} > /dev/null sudo apt install --yes --no-install-recommends ${CROWSNEST_CROWSNEST_DEPS} > /dev/null
echo -e "Installing 'crowsnest' Dependencies ... [OK]" echo -e "Installing 'crowsnest' Dependencies ... [OK]"
## Link webcamd to $PATH ## Link crowsnest to $PATH
echo -en "Linking webcamd ...\r" echo -en "Linking crowsnest ...\r"
sudo ln -sf "${webcamd_bin}" "${bin_path}" > /dev/null sudo ln -sf "${crowsnest_bin}" "${bin_path}" > /dev/null
echo -e "Linking webcamd ... [OK]\r" echo -e "Linking crowsnest ... [OK]\r"
## Copy webcam.conf ## Copy crowsnest.conf
# Make sure config directory exists! # Make sure config directory exists!
if [ ! -d "${CROWSNEST_DEFAULT_CONF_DIR}" ]; then if [ ! -d "${CROWSNEST_DEFAULT_CONF_DIR}" ]; then
sudo -u "${BASE_USER}" mkdir -p "${CROWSNEST_DEFAULT_CONF_DIR}" sudo -u "${BASE_USER}" mkdir -p "${CROWSNEST_DEFAULT_CONF_DIR}"
fi fi
# Make sure not to overwrite existing! # Make sure not to overwrite existing!
if [ ! -f "${CROWSNEST_DEFAULT_CONF_DIR}/webcam.conf" ]; then if [ ! -f "${CROWSNEST_DEFAULT_CONF_DIR}/crowsnest.conf" ]; then
echo -en "Copying webcam.conf ...\r" echo -en "Copying crowsnest.conf ...\r"
sudo -u "${BASE_USER}" cp -rf "${template}" "${CROWSNEST_DEFAULT_CONF_DIR}"/webcam.conf sudo -u "${BASE_USER}" cp -rf "${template}" "${CROWSNEST_DEFAULT_CONF_DIR}"/crowsnest.conf
echo -e "Copying webcam.conf ... [OK]\r" echo -e "Copying crowsnest.conf ... [OK]\r"
fi fi
## Copy webcamd.service ## Copy crowsnest.service
echo -en "Copying webcamd.service file ...\r" echo -en "Copying crowsnest.service file ...\r"
sudo cp -rf "${servicefile}" /etc/systemd/system/webcamd.service > /dev/null sudo cp -rf "${servicefile}" /etc/systemd/system/crowsnest.service > /dev/null
if [ ! "${BASE_USER}" == "pi" ]; then if [ ! "${BASE_USER}" == "pi" ]; then
sudo sed -i 's|pi|'"${BASE_USER}"'|g' /etc/systemd/system/webcamd.service sudo sed -i 's|pi|'"${BASE_USER}"'|g' /etc/systemd/system/crowsnest.service
fi fi
echo -e "Copying webcamd.service file ... [OK]\r" echo -e "Copying crowsnest.service file ... [OK]\r"
## Copy logrotate ## Copy logrotate
echo -en "Linking logrotate file ...\r" echo -en "Linking logrotate file ...\r"
sudo cp -rf "${logrotatefile}" /etc/logrotate.d/webcamd sudo cp -rf "${logrotatefile}" /etc/logrotate.d/crowsnest
if [ ! "${BASE_USER}" == "pi" ]; then if [ ! "${BASE_USER}" == "pi" ]; then
sudo sed -i 's|pi|'"${BASE_USER}"'|g' /etc/logrotate.d/webcamd sudo sed -i 's|pi|'"${BASE_USER}"'|g' /etc/logrotate.d/crowsnest
fi fi
echo -e "Linking logrotate file ... [OK]\r" echo -e "Linking logrotate file ... [OK]\r"
## update systemd if not unattended ## update systemd if not unattended
@@ -246,10 +246,10 @@ function install_crowsnest {
sudo systemctl daemon-reload sudo systemctl daemon-reload
echo -e "Reload systemd to enable new daemon ... [OK]" echo -e "Reload systemd to enable new daemon ... [OK]"
fi fi
## enable webcamd.service ## enable crowsnest.service
echo -en "Enable webcamd.service on boot ...\r" echo -en "Enable crowsnest.service on boot ...\r"
sudo systemctl enable webcamd.service sudo systemctl enable crowsnest.service
echo -e "Enable webcamd.service on boot ... [OK]\r" echo -e "Enable crowsnest.service on boot ... [OK]\r"
## Add moonraker update manager entry ## Add moonraker update manager entry
## Unattended ## Unattended
if [ "${UNATTENDED}" == "true" ] && if [ "${UNATTENDED}" == "true" ] &&
@@ -360,7 +360,7 @@ install_cleanup_trap
import_config import_config
welcome_msg welcome_msg
if [ "${UNATTENDED}" != "true" ]; then if [ "${UNATTENDED}" != "true" ]; then
detect_existing_webcamd detect_existing_crowsnest
fi fi
echo -e "Running apt update first ..." echo -e "Running apt update first ..."
sudo apt update sudo apt update

View File

@@ -1,5 +1,5 @@
#!/usr/bin/env bash #!/usr/bin/env bash
#### webcamd - A webcam Service for multiple Cams and Stream Services. #### crowsnest - A webcam Service for multiple Cams and Stream Services.
#### ####
#### Written by Stephan Wendel aka KwadFan <me@stephanwe.de> #### Written by Stephan Wendel aka KwadFan <me@stephanwe.de>
#### Copyright 2021 #### Copyright 2021
@@ -31,7 +31,7 @@ function welcome_msg {
function goodbye_msg { function goodbye_msg {
echo -e "Please remove manually the 'crowsnest' folder in ${HOME}" echo -e "Please remove manually the 'crowsnest' folder in ${HOME}"
echo -e "Remove [update manager webcamd] section from moonraker.conf!" echo -e "Remove [update manager crowsnest] section from moonraker.conf!"
echo -e "After that is done, please reboot!\nGoodBye...\n" echo -e "After that is done, please reboot!\nGoodBye...\n"
} }
@@ -71,7 +71,7 @@ trap 'err_exit $? $LINENO' ERR
### Uninstall crowsnest ### Uninstall crowsnest
function ask_uninstall { function ask_uninstall {
local remove local remove
if [ -x "/usr/local/bin/webcamd" ] && [ -d "${HOME}/crowsnest" ]; then if [ -x "/usr/local/bin/crowsnest" ] && [ -d "${HOME}/crowsnest" ]; then
read -rp "Do you REALLY want to remove existing 'crowsnest'? (YES/NO) " remove read -rp "Do you REALLY want to remove existing 'crowsnest'? (YES/NO) " remove
if [ "${remove}" = "YES" ]; then if [ "${remove}" = "YES" ]; then
uninstall_crowsnest uninstall_crowsnest
@@ -91,19 +91,19 @@ function ask_uninstall {
function uninstall_crowsnest { function uninstall_crowsnest {
local servicefile bin_path local servicefile bin_path
servicefile="/etc/systemd/system/webcamd.service" servicefile="/etc/systemd/system/crowsnest.service"
bin_path="/usr/local/bin/webcamd" bin_path="/usr/local/bin/crowsnest"
echo -en "\nStopping webcamd.service ...\r" echo -en "\nStopping crowsnest.service ...\r"
sudo systemctl stop webcamd.service &> /dev/null sudo systemctl stop crowsnest.service &> /dev/null
echo -e "Stopping webcamd.service ... \t[OK]\r" echo -e "Stopping crowsnest.service ... \t[OK]\r"
echo -en "Uninstalling webcamd.service...\r" echo -en "Uninstalling crowsnest.service...\r"
if [ -f "${servicefile}" ]; then if [ -f "${servicefile}" ]; then
sudo rm -f "${servicefile}" sudo rm -f "${servicefile}"
fi fi
if [ -x "${bin_path}" ]; then if [ -x "${bin_path}" ]; then
sudo rm -f "${bin_path}" sudo rm -f "${bin_path}"
fi fi
echo -e "Uninstalling webcamd.service...[OK]\r" echo -e "Uninstalling crowsnest.service...[OK]\r"
} }
function remove_raspicam_fix { function remove_raspicam_fix {
@@ -122,7 +122,7 @@ function remove_raspicam_fix {
function remove_logrotate { function remove_logrotate {
echo -en "Removing Logrotate Rule ...\r" echo -en "Removing Logrotate Rule ...\r"
sudo rm -f /etc/logrotate.d/webcamd sudo rm -f /etc/logrotate.d/crowsnest
echo -e "Removing Logrotate Rule ... [OK]" echo -e "Removing Logrotate Rule ... [OK]"
} }