From 104536cd21ab5d49925274a1a5dd7eb9df9fdeea Mon Sep 17 00:00:00 2001 From: Stephan Wendel Date: Sun, 12 Jun 2022 11:54:32 +0200 Subject: [PATCH] refactor!: renaming webcamd to crowsnest BREAKING CHANGE: This will require a reinstall of crowsnest Signed-off-by: Stephan Wendel --- bin/Makefile | 2 +- webcamd => crowsnest | 8 +- custompios/crowsnest/config | 2 +- custompios/crowsnest/start_chroot_script | 2 +- file_templates/bcm2835-v4l2.conf | 2 +- .../{webcamd.service => crowsnest.service} | 9 +- ...{logrotate_webcamd => logrotate_crowsnest} | 6 +- file_templates/moonraker_update.txt | 3 +- libs/configparser.sh | 10 +- libs/core.sh | 8 +- libs/hwhandler.sh | 2 +- libs/init_stream.sh | 2 +- libs/logging.sh | 24 ++-- libs/messages.sh | 16 +-- libs/rtspsimple.sh | 2 +- libs/ustreamer.sh | 2 +- libs/v4l2_control.sh | 2 +- libs/versioncontrol.sh | 2 +- libs/watchdog.sh | 10 +- sample_configs/mainsail_default.conf | 30 ++++- sample_configs/minimal.conf | 32 +++-- tools/config.bullseye | 2 +- tools/config.buster | 2 +- tools/config.local.example | 2 +- tools/config.x86 | 2 +- tools/install.sh | 110 +++++++++--------- tools/uninstall.sh | 22 ++-- 27 files changed, 173 insertions(+), 143 deletions(-) rename webcamd => crowsnest (88%) rename file_templates/{webcamd.service => crowsnest.service} (67%) rename file_templates/{logrotate_webcamd => logrotate_crowsnest} (68%) diff --git a/bin/Makefile b/bin/Makefile index 621a80b..0d3ed16 100644 --- a/bin/Makefile +++ b/bin/Makefile @@ -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 #### Copyright 2021 diff --git a/webcamd b/crowsnest similarity index 88% rename from webcamd rename to crowsnest index 446f262..b5ff9c4 100755 --- a/webcamd +++ b/crowsnest @@ -2,7 +2,7 @@ #### 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 #### Copyright 2021 @@ -44,7 +44,7 @@ fi while getopts ":vhc:" arg; do case "${arg}" in v ) - echo -e "\nwebcamd Version: $(self_version)\n" + echo -e "\ncrowsnest Version: $(self_version)\n" exit 0 ;; h ) @@ -53,7 +53,7 @@ while getopts ":vhc:" arg; do ;; c ) check_cfg "${OPTARG}" - export WEBCAMD_CFG="${OPTARG}" + export CROWSNEST_CFG="${OPTARG}" ;; \?) wrong_args_msg @@ -73,7 +73,7 @@ brokenfocus ## The User gets a message if Device is lost. clean_watchdog while true ; do - webcamd_watchdog + crowsnest_watchdog sleep 120 & sleep_pid="$!" wait "${sleep_pid}" done diff --git a/custompios/crowsnest/config b/custompios/crowsnest/config index 2f3d1ef..d12c02d 100644 --- a/custompios/crowsnest/config +++ b/custompios/crowsnest/config @@ -1,5 +1,5 @@ #!/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 #### Copyright 2021 diff --git a/custompios/crowsnest/start_chroot_script b/custompios/crowsnest/start_chroot_script index c60770b..9f75b2c 100644 --- a/custompios/crowsnest/start_chroot_script +++ b/custompios/crowsnest/start_chroot_script @@ -1,6 +1,6 @@ #!/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 #### Copyright 2021 diff --git a/file_templates/bcm2835-v4l2.conf b/file_templates/bcm2835-v4l2.conf index c40662c..6d6f446 100644 --- a/file_templates/bcm2835-v4l2.conf +++ b/file_templates/bcm2835-v4l2.conf @@ -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 #### Copyright 2021 diff --git a/file_templates/webcamd.service b/file_templates/crowsnest.service similarity index 67% rename from file_templates/webcamd.service rename to file_templates/crowsnest.service index f32b91c..2973af1 100644 --- a/file_templates/webcamd.service +++ b/file_templates/crowsnest.service @@ -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 #### Copyright 2021 @@ -8,7 +8,7 @@ #### [Unit] -Description=webcamd - Multi Webcam/Streamer Control Deamon +Description=crowsnest - Multi Webcam/Streamer Control Deamon Documentation=https://github.com/mainsail-crew/crowsnest After=udev.service network-online.target nss-lookup.target Wants=udev.service network-online.target @@ -17,14 +17,13 @@ StartLimitBurst=10 StartLimitIntervalSec=180 [Install] -Alias=crowsnest WantedBy=multi-user.target [Service] -Environment=WEBCAMD_CONFIG=/home/pi/klipper_config/webcam.conf +Environment=CROWSNEST_CONFIG=/home/pi/klipper_config/crowsnest.conf Type=exec User=pi RemainAfterExit=Yes -ExecStart= /usr/local/bin/webcamd -c ${WEBCAMD_CONFIG} +ExecStart= /usr/local/bin/crowsnest -c ${CROWSNEST_CONFIG} Restart=on-failure RestartSec=5 diff --git a/file_templates/logrotate_webcamd b/file_templates/logrotate_crowsnest similarity index 68% rename from file_templates/logrotate_webcamd rename to file_templates/logrotate_crowsnest index cacc3fb..eb0e8ee 100644 --- a/file_templates/logrotate_webcamd +++ b/file_templates/logrotate_crowsnest @@ -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 #### Copyright 2021 @@ -10,7 +10,7 @@ #### -/home/pi/klipper_logs/webcamd.log { +/home/pi/klipper_logs/crowsnest.log { rotate 3 missingok notifempty diff --git a/file_templates/moonraker_update.txt b/file_templates/moonraker_update.txt index 2928aa6..97d612f 100644 --- a/file_templates/moonraker_update.txt +++ b/file_templates/moonraker_update.txt @@ -1,6 +1,7 @@ # Crowsnest update_manager entry -[update_manager webcamd] +[update_manager crowsnest] type: git_repo path: ~/crowsnest origin: https://github.com/mainsail-crew/crowsnest.git +managed_services: crowsnest diff --git a/libs/configparser.sh b/libs/configparser.sh index 6d8a85e..5019294 100755 --- a/libs/configparser.sh +++ b/libs/configparser.sh @@ -2,7 +2,7 @@ #### 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 #### Copyright 2021 @@ -21,7 +21,7 @@ set -Ee # spits out raw value function get_param { local cfg section param - cfg="${WEBCAMD_CFG}" + cfg="${CROWSNEST_CFG}" section="${1}" param="${2}" crudini --get "${cfg}" "${section}" "${param}" 2> /dev/null | \ @@ -40,9 +40,9 @@ function check_cfg { ## Spits out all [cam ] configured sections function configured_cams { local cams cfg - cfg="${WEBCAMD_CFG}" + cfg="${CROWSNEST_CFG}" for i in $(crudini --existing=file --get "${cfg}" | \ - sed '/webcamd/d;s/cam//'); do + sed '/crowsnest/d;s/cam//'); do cams+=("${i}") done echo "${cams[@]}" @@ -54,7 +54,7 @@ function check_section { local section exist param must_exist missing section="cam ${1}" # 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')" for i in ${exist}; do param+=("${i}") diff --git a/libs/core.sh b/libs/core.sh index 695fc5f..95ae761 100755 --- a/libs/core.sh +++ b/libs/core.sh @@ -2,7 +2,7 @@ #### 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 #### Copyright 2021 @@ -16,7 +16,7 @@ # Exit upon Errors set -Ee -## Version of webcamd +## Version of crowsnest function self_version { pushd "${BASE_CN_PATH}" &> /dev/null git describe --always --tags @@ -116,13 +116,13 @@ function initial_check { check_apps versioncontrol # 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 print_cfg fi fi # in systemd show always config file - logger -t webcamd -f "${WEBCAMD_CFG}" + logger -t crowsnest -f "${CROWSNEST_CFG}" log_msg "INFO: Detect available Devices" print_cams } diff --git a/libs/hwhandler.sh b/libs/hwhandler.sh index 0283c96..095d11f 100755 --- a/libs/hwhandler.sh +++ b/libs/hwhandler.sh @@ -2,7 +2,7 @@ #### 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 #### Copyright 2021 diff --git a/libs/init_stream.sh b/libs/init_stream.sh index 0bc3ed1..6b6c293 100755 --- a/libs/init_stream.sh +++ b/libs/init_stream.sh @@ -2,7 +2,7 @@ #### 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 #### Copyright 2021 diff --git a/libs/logging.sh b/libs/logging.sh index 4b49ed2..6587495 100755 --- a/libs/logging.sh +++ b/libs/logging.sh @@ -2,7 +2,7 @@ #### 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 #### Copyright 2021 @@ -19,7 +19,7 @@ set -Ee ## Logging function set_log_path { #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 #Workaround: Make Dir if not exist if [ ! -d "$(dirname "${CROWSNEST_LOG_PATH}")" ]; then @@ -30,14 +30,14 @@ function set_log_path { function init_logging { set_log_path 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 "Prepare Startup ..." } function log_level { 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 if [ -z "${loglevel}" ] || [[ "${loglevel}" != @(quiet|verbose|debug) ]]; then @@ -49,7 +49,7 @@ function log_level { function delete_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 rm -rf "${CROWSNEST_LOG_PATH}" fi @@ -58,9 +58,9 @@ function delete_log { function log_msg { local msg prefix msg="${1}" - prefix="$(date +'[%D %T]') webcamd:" - echo -e "${prefix} ${msg}" | tr -s ' ' >> "${CROWSNEST_LOG_PATH}" 2>&1 - echo -e "${msg}" | logger -t webcamd + prefix="$(date +'[%D %T]') crowsnest:" + echo -e "${prefix} ${msg}" | tr -s ' ' | tee -a "${CROWSNEST_LOG_PATH}" 2>&1 + echo -e "${msg}" | logger -t crowsnest } #call '| log_output ""' @@ -73,7 +73,7 @@ function log_output { fi if [ -n "${line}" ]; then # needed to prettify ustreamers output - echo "${line//^--/ustreamer}" | logger -t webcamd + echo "${line//^--/ustreamer}" | logger -t crowsnest fi done } @@ -81,10 +81,10 @@ function log_output { function print_cfg { local prefix prefix="\t\t" - log_msg "INFO: Print Configfile: '${WEBCAMD_CFG}'" + log_msg "INFO: Print Configfile: '${CROWSNEST_CFG}'" while read -r line; do log_msg "${prefix}${line}" - done < "${WEBCAMD_CFG}" + done < "${CROWSNEST_CFG}" } function print_cams { @@ -120,6 +120,6 @@ function debug_msg { prefix="Develop -- DEBUG:" while read -r msg; do log_msg "${prefix} ${msg}" - echo -e "${msg}" | logger -t webcamd + echo -e "${msg}" | logger -t crowsnest done <<< "${1}" } diff --git a/libs/messages.sh b/libs/messages.sh index d650c81..04a281f 100755 --- a/libs/messages.sh +++ b/libs/messages.sh @@ -2,7 +2,7 @@ #### 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 #### Copyright 2021 @@ -20,20 +20,20 @@ set -Ee ## core lib function missing_args_msg { - echo -e "webcamd: Missing Arguments!" - echo -e "\n\tTry: webcamd -h\n" + echo -e "crowsnest: Missing Arguments!" + echo -e "\n\tTry: crowsnest -h\n" } function wrong_args_msg { - echo -e "webcamd: Wrong Arguments!" - echo -e "\n\tTry: webcamd -h\n" + echo -e "crowsnest: Wrong Arguments!" + echo -e "\n\tTry: crowsnest -h\n" } function help_msg { - echo -e "webcamd - webcam deamon\nUsage:" - echo -e "\t webcamd [Options]" + echo -e "crowsnest - webcam deamon\nUsage:" + echo -e "\t crowsnest [Options]" 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 \n\t\t\tPath to your webcam.conf\n" } diff --git a/libs/rtspsimple.sh b/libs/rtspsimple.sh index 1dc15d1..e95f426 100755 --- a/libs/rtspsimple.sh +++ b/libs/rtspsimple.sh @@ -2,7 +2,7 @@ #### 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 #### Copyright 2021 diff --git a/libs/ustreamer.sh b/libs/ustreamer.sh index cb539b3..1b81f96 100755 --- a/libs/ustreamer.sh +++ b/libs/ustreamer.sh @@ -2,7 +2,7 @@ #### 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 #### Copyright 2021 diff --git a/libs/v4l2_control.sh b/libs/v4l2_control.sh index f188439..ebf42f4 100755 --- a/libs/v4l2_control.sh +++ b/libs/v4l2_control.sh @@ -2,7 +2,7 @@ #### 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 #### Copyright 2021 diff --git a/libs/versioncontrol.sh b/libs/versioncontrol.sh index 251383d..9348a95 100644 --- a/libs/versioncontrol.sh +++ b/libs/versioncontrol.sh @@ -2,7 +2,7 @@ #### 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 #### Copyright 2021 diff --git a/libs/watchdog.sh b/libs/watchdog.sh index 6470cdf..b134a90 100755 --- a/libs/watchdog.sh +++ b/libs/watchdog.sh @@ -2,7 +2,7 @@ #### 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 #### Copyright 2021 @@ -24,7 +24,7 @@ function clean_watchdog { rm -f /tmp/lost-* } -function webcamd_watchdog { +function crowsnest_watchdog { # Helper Functions function available { find "${1}" &> /dev/null @@ -52,8 +52,8 @@ function webcamd_watchdog { function get_conf_devices { local gcd - for i in $(crudini --existing=file --get "${WEBCAMD_CFG}" | \ - sed '/webcamd/d' | cut -d ' ' -f2); do + for i in $(crudini --existing=file --get "${CROWSNEST_CFG}" | \ + sed '/crowsnest/d' | cut -d ' ' -f2); do gcd+=("${i}") done echo "${gcd[@]}" @@ -62,7 +62,7 @@ function webcamd_watchdog { ### MAIN 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}')" if [ "$(available "${cc}")" -ne 0 ] && [ "$(is_lost "${cc}")" -ne 0 ]; then log_msg "WATCHDOG: Lost Device: '${cc}'" diff --git a/sample_configs/mainsail_default.conf b/sample_configs/mainsail_default.conf index aa08a0f..19cb7d5 100644 --- a/sample_configs/mainsail_default.conf +++ b/sample_configs/mainsail_default.conf @@ -1,16 +1,34 @@ -### webcam.conf -### This is mainsail / MainsailOS default config. -### See docs.mainsail.xyz/whatever for Details to configure to your needs. +#### crowsnest.conf +#### This is mainsail / MainsailOS default config. +#### 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 +delete_log: false # Deletes log on every restart, if set to true [cam 1] -mode: mjpg # mjpg/rtsp/webrtc +mode: mjpg # mjpg/rtsp port: 8080 # Port device: /dev/video0 # See Log for available ... resolution: 640x480 # widthxheight format 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. +#v4l2ctl: # Add v4l2-ctl parameters to setup your camera, see Log what your cam is capable of. diff --git a/sample_configs/minimal.conf b/sample_configs/minimal.conf index 5b56028..f37b10e 100644 --- a/sample_configs/minimal.conf +++ b/sample_configs/minimal.conf @@ -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 -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] -mode: mjpg # mjpg/rtsp/webrtc ( webrtc is comming in the future ) -port: 8080 # Port for ustreamer +mode: mjpg # mjpg/rtsp +port: 8080 # Port 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. -#custom_flags: # Custom Flags to set for ustreamer, this is optional - diff --git a/tools/config.bullseye b/tools/config.bullseye index fd0ed78..d9adb56 100644 --- a/tools/config.bullseye +++ b/tools/config.bullseye @@ -1,5 +1,5 @@ #!/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 #### Copyright 2021 diff --git a/tools/config.buster b/tools/config.buster index 7bca6f3..9d85a8f 100644 --- a/tools/config.buster +++ b/tools/config.buster @@ -1,5 +1,5 @@ #!/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 #### Copyright 2021 diff --git a/tools/config.local.example b/tools/config.local.example index 33e9273..c29c34b 100644 --- a/tools/config.local.example +++ b/tools/config.local.example @@ -1,5 +1,5 @@ #!/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 #### Copyright 2021 diff --git a/tools/config.x86 b/tools/config.x86 index 4bb070b..bee2d44 100644 --- a/tools/config.x86 +++ b/tools/config.x86 @@ -1,5 +1,5 @@ #!/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 #### Copyright 2021 diff --git a/tools/install.sh b/tools/install.sh index 367eb4f..280050e 100755 --- a/tools/install.sh +++ b/tools/install.sh @@ -40,7 +40,7 @@ function welcome_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 "You can use KIAUH for example to reinstall.\n" } @@ -128,17 +128,17 @@ function import_config { fi } -### Detect webcamd. -function detect_existing_webcamd { +### Detect crowsnest. +function detect_existing_crowsnest { 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 - 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 - echo -en "\nStopping webcamd.service ...\r" - sudo systemctl stop webcamd.service &> /dev/null - echo -e "Stopping webcamd.service ... \t[OK]\r" - remove_existing_webcamd + echo -en "\nStopping crowsnest.service ...\r" + sudo systemctl stop crowsnest.service &> /dev/null + echo -e "Stopping crowsnest.service ... \t[OK]\r" + remove_existing_crowsnest else echo -e "\nYou answered '${remove}'! Installation will be aborted..." echo -e "GoodBye...\n" @@ -147,47 +147,47 @@ function detect_existing_webcamd { fi } -### Remove existing webcamd -function remove_existing_webcamd { - if [ -x "/usr/local/bin/webcamd" ]; then - echo -en "Removing 'webcamd' ...\r" - sudo rm -f /usr/local/bin/webcamd > /dev/null - echo -e "Removing 'webcamd' ... \t\t[OK]\r" +### Remove existing crowsnest +function remove_existing_crowsnest { + if [ -x "/usr/local/bin/crowsnest" ]; then + echo -en "Removing 'crowsnest' ...\r" + sudo rm -f /usr/local/bin/crowsnest > /dev/null + echo -e "Removing 'crowsnest' ... \t\t[OK]\r" fi if [ -d "${HOME}/mjpg-streamer" ]; then echo -en "Removing 'mjpg-streamer' ...\r" sudo rm -rf "${HOME}"/mjpg-streamer > /dev/null echo -e "Removing 'mjpg-streamer' ... \t[OK]\r" fi - if [ -f "/etc/systemd/system/webcamd.service" ]; then - echo -en "Removing 'webcamd.service' ...\r" - sudo rm -f /etc/systemd/system/webcamd.service > /dev/null - echo -e "Removing 'webcamd.service' ... \t[OK]\r" + if [ -f "/etc/systemd/system/crowsnest.service" ]; then + echo -en "Removing 'crowsnest.service' ...\r" + sudo rm -f /etc/systemd/system/crowsnest.service > /dev/null + echo -e "Removing 'crowsnest.service' ... \t[OK]\r" fi - if [ -f "/var/log/webcamd.log" ]; then - echo -en "Removing 'webcamd.log' ...\r" - sudo rm -f /var/log/webcamd.log > /dev/null - sudo rm -f "${HOME}"/klipper_logs/webcamd.log > /dev/null - echo -e "Removing 'webcamd.log' ... \t[OK]\r" + if [ -f "/var/log/crowsnest.log" ]; then + echo -en "Removing 'crowsnest.log' ...\r" + sudo rm -f /var/log/crowsnest.log > /dev/null + sudo rm -f "${HOME}"/klipper_logs/crowsnest.log > /dev/null + echo -e "Removing 'crowsnest.log' ... \t[OK]\r" fi - if [ -f "/etc/logrotate.d/webcamd" ]; then - echo -en "Removing 'webcamd' logrotate...\r" - sudo rm -f /etc/logrotate.d/webcamd > /dev/null - echo -e "Removing 'webcamd' logrotate ... \t[OK]\r" + if [ -f "/etc/logrotate.d/crowsnest" ]; then + echo -en "Removing 'crowsnest' logrotate...\r" + sudo rm -f /etc/logrotate.d/crowsnest > /dev/null + echo -e "Removing 'crowsnest' logrotate ... \t[OK]\r" fi - echo -e "\nOld 'webcamd' completly removed." + echo -e "\nOld 'crowsnest' completly removed." echo -e "webcam.txt kept,but no longer necessary ..." } function install_crowsnest { local addconf bin_path logrotatefile moonraker_conf moonraker_update - local webcamd_bin servicefile template + local crowsnest_bin servicefile template bin_path="/usr/local/bin" - webcamd_bin="${HOME}/crowsnest/webcamd" + crowsnest_bin="${HOME}/crowsnest/crowsnest" template="${PWD}/sample_configs/${CROWSNEST_DEFAULT_CONF}" - servicefile="${PWD}/file_templates/webcamd.service" - logrotatefile="${HOME}/crowsnest/file_templates/logrotate_webcamd" + servicefile="${PWD}/file_templates/crowsnest.service" + logrotatefile="${HOME}/crowsnest/file_templates/logrotate_crowsnest" moonraker_conf="${HOME}/klipper_config/moonraker.conf" moonraker_update="${PWD}/file_templates/moonraker_update.txt" ## helper func moonraker update_manager @@ -205,39 +205,39 @@ function install_crowsnest { echo -e "moonraker.conf is missing ... [SKIPPED]" fi } - echo -e "\nInstall webcamd Service ..." + echo -e "\nInstall crowsnest Service ..." ## Install Dependencies echo -e "Installing 'crowsnest' Dependencies ..." # shellcheck disable=2086 sudo apt install --yes --no-install-recommends ${CROWSNEST_CROWSNEST_DEPS} > /dev/null echo -e "Installing 'crowsnest' Dependencies ... [OK]" - ## Link webcamd to $PATH - echo -en "Linking webcamd ...\r" - sudo ln -sf "${webcamd_bin}" "${bin_path}" > /dev/null - echo -e "Linking webcamd ... [OK]\r" - ## Copy webcam.conf + ## Link crowsnest to $PATH + echo -en "Linking crowsnest ...\r" + sudo ln -sf "${crowsnest_bin}" "${bin_path}" > /dev/null + echo -e "Linking crowsnest ... [OK]\r" + ## Copy crowsnest.conf # Make sure config directory exists! if [ ! -d "${CROWSNEST_DEFAULT_CONF_DIR}" ]; then sudo -u "${BASE_USER}" mkdir -p "${CROWSNEST_DEFAULT_CONF_DIR}" fi # Make sure not to overwrite existing! - if [ ! -f "${CROWSNEST_DEFAULT_CONF_DIR}/webcam.conf" ]; then - echo -en "Copying webcam.conf ...\r" - sudo -u "${BASE_USER}" cp -rf "${template}" "${CROWSNEST_DEFAULT_CONF_DIR}"/webcam.conf - echo -e "Copying webcam.conf ... [OK]\r" + if [ ! -f "${CROWSNEST_DEFAULT_CONF_DIR}/crowsnest.conf" ]; then + echo -en "Copying crowsnest.conf ...\r" + sudo -u "${BASE_USER}" cp -rf "${template}" "${CROWSNEST_DEFAULT_CONF_DIR}"/crowsnest.conf + echo -e "Copying crowsnest.conf ... [OK]\r" fi - ## Copy webcamd.service - echo -en "Copying webcamd.service file ...\r" - sudo cp -rf "${servicefile}" /etc/systemd/system/webcamd.service > /dev/null + ## Copy crowsnest.service + echo -en "Copying crowsnest.service file ...\r" + sudo cp -rf "${servicefile}" /etc/systemd/system/crowsnest.service > /dev/null 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 - echo -e "Copying webcamd.service file ... [OK]\r" + echo -e "Copying crowsnest.service file ... [OK]\r" ## Copy logrotate 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 - 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 echo -e "Linking logrotate file ... [OK]\r" ## update systemd if not unattended @@ -246,10 +246,10 @@ function install_crowsnest { sudo systemctl daemon-reload echo -e "Reload systemd to enable new daemon ... [OK]" fi - ## enable webcamd.service - echo -en "Enable webcamd.service on boot ...\r" - sudo systemctl enable webcamd.service - echo -e "Enable webcamd.service on boot ... [OK]\r" + ## enable crowsnest.service + echo -en "Enable crowsnest.service on boot ...\r" + sudo systemctl enable crowsnest.service + echo -e "Enable crowsnest.service on boot ... [OK]\r" ## Add moonraker update manager entry ## Unattended if [ "${UNATTENDED}" == "true" ] && @@ -360,7 +360,7 @@ install_cleanup_trap import_config welcome_msg if [ "${UNATTENDED}" != "true" ]; then - detect_existing_webcamd + detect_existing_crowsnest fi echo -e "Running apt update first ..." sudo apt update diff --git a/tools/uninstall.sh b/tools/uninstall.sh index e055445..20daa12 100755 --- a/tools/uninstall.sh +++ b/tools/uninstall.sh @@ -1,5 +1,5 @@ #!/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 #### Copyright 2021 @@ -31,7 +31,7 @@ function welcome_msg { function goodbye_msg { 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" } @@ -71,7 +71,7 @@ trap 'err_exit $? $LINENO' ERR ### Uninstall crowsnest function ask_uninstall { 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 if [ "${remove}" = "YES" ]; then uninstall_crowsnest @@ -91,19 +91,19 @@ function ask_uninstall { function uninstall_crowsnest { local servicefile bin_path - servicefile="/etc/systemd/system/webcamd.service" - bin_path="/usr/local/bin/webcamd" - echo -en "\nStopping webcamd.service ...\r" - sudo systemctl stop webcamd.service &> /dev/null - echo -e "Stopping webcamd.service ... \t[OK]\r" - echo -en "Uninstalling webcamd.service...\r" + servicefile="/etc/systemd/system/crowsnest.service" + bin_path="/usr/local/bin/crowsnest" + echo -en "\nStopping crowsnest.service ...\r" + sudo systemctl stop crowsnest.service &> /dev/null + echo -e "Stopping crowsnest.service ... \t[OK]\r" + echo -en "Uninstalling crowsnest.service...\r" if [ -f "${servicefile}" ]; then sudo rm -f "${servicefile}" fi if [ -x "${bin_path}" ]; then sudo rm -f "${bin_path}" fi - echo -e "Uninstalling webcamd.service...[OK]\r" + echo -e "Uninstalling crowsnest.service...[OK]\r" } function remove_raspicam_fix { @@ -122,7 +122,7 @@ function remove_raspicam_fix { function remove_logrotate { 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]" }