refactor: refactor of User input during install

Show default answers in case of user only hits enter.

Includes fix: Install on rpi bullseye fails

This also should fix #24

Signed-off-by: Stephan Wendel <me@stephanwe.de>
This commit is contained in:
Stephan Wendel 2022-08-12 21:58:47 +02:00
parent 2fb45c3283
commit 8df5078b3d
No known key found for this signature in database
GPG Key ID: F465B83ACBA45639
5 changed files with 81 additions and 44 deletions

View File

@ -30,18 +30,26 @@ MAKEFLAGS += -j$(shell nproc)
# OpenMAX IL Support
OMX_SUPPORT = $(shell [ -d /opt/vc/include ] && echo 1 || echo 0)
# Ustreamer cloned?
USTREAMER_EXIST = $(shell [ -d ustreamer ] > /dev/null && echo 1 || echo 0)
all:
$(MAKE) ustreamer
ifeq ($(USTREAMER_EXIST), 0)
$(info INFO: ustreamer not found, cloning repository.)
$(shell git clone $(USTREAMER_REPO) ustreamer)
else
$(info INFO: ustreamer found.)
endif
$(MAKE) ustreamer-bin
$(MAKE) rtsp
# Build ustreamer
ustreamer:
$(shell if ! [ -d "bin/ustreamer" ]; then \
git clone $(USTREAMER_REPO) ustreamer; fi)
ustreamer-bin:
ifeq ($(OMX_SUPPORT), 1)
$(shell cd ustreamer; git reset -q --hard $(USTREAMER_OMX_BRANCH) &> /dev/null \
; cd ..)
$(info Compiling ustreamer with OMX Support.)
$(info Changening to commit '$(USTREAMER_OMX_BRANCH)' )
$(shell cd ustreamer; git reset -q --hard $(USTREAMER_OMX_BRANCH) \
; cd ..)
WITH_OMX=1 $(MAKE) -C $(USTREAMER_PATH)
else
$(info Compiling ustreamer without OMX Support.)

View File

@ -111,19 +111,17 @@ function import_config {
## rpi os buster
if [ "$(uname -m)" != "x86_64" ] &&
[ "$(cut -d " " -f1 < /proc/device-tree/model)" == "Raspberry" ] &&
[ "$(get_os_version buster)" != "0" ] &&
[ -f "tools/config.rpi-buster" ]; then
# shellcheck disable=SC1091
source tools/config.rpi-buster
source tools/config.buster
return 0
fi
## rpi os bullseye
## bullseye
if [ "$(uname -m)" != "x86_64" ] &&
[ "$(get_os_version bullseye)" != "0" ] &&
[ "$(cut -d " " -f1 < /proc/device-tree/model)" == "Raspberry" ] &&
[ -f "tools/config.rpi-bullseye" ]; then
[ -f "tools/config.bullseye" ]; then
# shellcheck disable=SC1091
source tools/config.bullseye
return 0
@ -174,17 +172,27 @@ function detect_existing_webcamd {
local remove
if [ -x "/usr/local/bin/webcamd" ] && [ -d "${HOME}/mjpg-streamer" ]; then
detect_msg
read -rp "Do you want to remove existing 'webcamd'? (YES/NO) " remove
if [ "${remove}" = "YES" ]; then
read -erp "Do you want to remove existing 'webcamd'? (y/N) " -i "N" remove
case "${remove}" in
y|Y|yes|Yes|YES)
echo -en "\nStopping webcamd.service ...\r"
sudo systemctl stop webcamd.service &> /dev/null
echo -e "Stopping webcamd.service ... \t[OK]\r"
remove_existing_webcamd
else
echo -e "\nYou answered '${remove}'! Installation will be aborted..."
;;
n|N|no|No|NO)
echo -e "\nYou have to remove webcamd to use crowsnest!"
echo -e "Installation will be aborted..."
echo -e "GoodBye...\n"
exit 1
fi
;;
*)
echo -e "\nYou answered '${remove}'! Invalid input ... [EXITING]"
echo -e "GoodBye...\n"
exit 1
;;
esac
fi
}
@ -294,7 +302,7 @@ function install_crowsnest {
fi
## enable crowsnest.service
echo -en "Enable crowsnest.service on boot ...\r"
sudo systemctl enable crowsnest.service
sudo systemctl enable crowsnest.service &> /dev/null
echo -e "Enable crowsnest.service on boot ... [OK]\r"
## Add moonraker update manager entry
## Unattended
@ -308,16 +316,28 @@ function install_crowsnest {
## Manual install
if [ "${UNATTENDED}" != "true" ] &&
[ "${CROWSNEST_ADD_CROWSNEST_MOONRAKER}" != "0" ]; then
read -rp "Do you want to add [update_manager] entry?(y/n) " addconf
while true; do
read -erp "Do you want to add [update_manager] entry? (y/N) " -i "N" addconf
case "${addconf}" in
y*|Y*)
y|Y|yes|Yes|YES)
if [ "$(grep -c "crowsnest" "${moonraker_conf}")" == "0" ]; then
add_update_entry
else
echo -e "Update Manager entry already exists moonraker.conf ... [SKIPPED]"
fi
break
;;
n*|N*)
n|N|no|No|NO)
echo -e "Adding Crowsnest Update Manager entry to moonraker.conf ... [SKIPPED]"
break
;;
*)
echo -e "\nInvalid input, please try again."
;;
esac
done
fi
## add $USER to group video

View File

@ -72,17 +72,26 @@ trap 'err_exit $? $LINENO' ERR
function ask_uninstall {
local remove
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
while true; do
read -erp "Do you REALLY want to remove existing 'crowsnest'? (y/N) " -i "N" remove
case "${remove}" in
y|Y|yes|Yes|YES)
uninstall_crowsnest
remove_raspicam_fix
remove_logrotate
goodbye_msg
else
break
;;
n|N|no|No|NO)
echo -e "\nYou answered '${remove}'! Uninstall will be aborted..."
echo -e "GoodBye...\n"
exit 1
fi
;;
*)
echo -e "\nInvalid input, please try again."
;;
esac
done
else
echo -e "\n'crowsnest' seems not installed."
echo -e "Exiting. GoodBye ..."