From 44e2d07a4f137a49ee847df27e573acff2a27952 Mon Sep 17 00:00:00 2001 From: Patrick Gehrsitz Date: Wed, 22 Nov 2023 20:53:49 +0100 Subject: [PATCH] chore: add check to disable webcamd (#211) Signed-off-by: Patrick Gehrsitz --- tools/install.sh | 1 + tools/libs/core.sh | 33 +++++++++++++++++++++++++++++++++ 2 files changed, 34 insertions(+) diff --git a/tools/install.sh b/tools/install.sh index 5483561b..6a945af6 100755 --- a/tools/install.sh +++ b/tools/install.sh @@ -65,6 +65,7 @@ main() { if [[ "${CROWSNEST_UNATTENDED}" != "1" ]]; then msg "Doing some tests ...\n" + detect_existing_webcamd if shallow_cs_dependencies_check; then CN_INSTALL_CS="1" else diff --git a/tools/libs/core.sh b/tools/libs/core.sh index 23ebed4b..3c843494 100755 --- a/tools/libs/core.sh +++ b/tools/libs/core.sh @@ -282,3 +282,36 @@ dietpi_cs_settings() { fi fi } + +### Detect legacy webcamd. +detect_existing_webcamd() { + local disable + msg "Checking for mjpg-streamer ...\n" + if [[ -x "/usr/local/bin/webcamd" ]] && [[ -d "/home/${BASE_USER}/mjpg-streamer" ]]; then + msg "Found an existing mjpg-streamer installation!" + msg "This should be stopped and disabled!" + while true; do + read -erp "Do you want to stop and disable existing 'webcamd'? (Y/n) " -i "Y" disable + case "${disable}" in + y|Y|yes|Yes|YES) + msg "Stopping webcamd.service ..." + sudo systemctl stop webcamd.service &> /dev/null + status_msg "Stopping webcamd.service ..." "0" + + msg "\nDisabling webcamd.service ...\r" + sudo systemctl disable webcamd.service &> /dev/null + status_msg "Disabling webcamd.service ..." "0" + return + ;; + + n|N|no|No|NO) + msg "\nYou should disable and stop webcamd to use crowsnest without problems!\n" + return + ;; + *) + msg "You answered '${disable}'! Invalid input ..." ;; + esac + done + fi + status_msg "Checking for mjpg-streamer ..." "0" +}