Skip to content

Commit

Permalink
refactor: refactor of User input during install
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
KwadFan committed Aug 16, 2022
1 parent 2fb45c3 commit 8df5078
Show file tree
Hide file tree
Showing 5 changed files with 82 additions and 45 deletions.
20 changes: 14 additions & 6 deletions bin/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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.)
Expand Down
File renamed without changes.
File renamed without changes.
74 changes: 47 additions & 27 deletions tools/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
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..."
echo -e "GoodBye...\n"
exit 1
fi
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
;;

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
;;
*)
echo -e "\nYou answered '${remove}'! Invalid input ... [EXITING]"
echo -e "GoodBye...\n"
exit 1
;;
esac
fi
}

Expand Down Expand Up @@ -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
Expand All @@ -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
case "${addconf}" in
y*|Y*)
add_update_entry
;;

n*|N*)
echo -e "Adding Crowsnest Update Manager entry to moonraker.conf ... [SKIPPED]"
;;
esac
while true; do
read -erp "Do you want to add [update_manager] entry? (y/N) " -i "N" addconf
case "${addconf}" in
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|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
Expand Down
33 changes: 21 additions & 12 deletions tools/uninstall.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
uninstall_crowsnest
remove_raspicam_fix
remove_logrotate
goodbye_msg
else
echo -e "\nYou answered '${remove}'! Uninstall will be aborted..."
echo -e "GoodBye...\n"
exit 1
fi
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
break
;;
n|N|no|No|NO)
echo -e "\nYou answered '${remove}'! Uninstall will be aborted..."
echo -e "GoodBye...\n"
exit 1
;;
*)
echo -e "\nInvalid input, please try again."
;;
esac
done
else
echo -e "\n'crowsnest' seems not installed."
echo -e "Exiting. GoodBye ..."
Expand All @@ -98,7 +107,7 @@ function uninstall_crowsnest {
echo -e "Stopping crowsnest.service ... \t[OK]\r"
echo -en "\nDisable crowsnest.service ...\r"
sudo systemctl disable crowsnest.service &> /dev/null
echo -e "Disablecrowsnest.service ... \t[OK]\r"
echo -e "Disable crowsnest.service ... \t[OK]\r"
echo -en "Uninstalling crowsnest.service...\r"
if [ -f "${servicefile}" ]; then
sudo rm -f "${servicefile}"
Expand Down

0 comments on commit 8df5078

Please sign in to comment.