feat(install): add unattended mode to installer

Unattended ignores to enable the service and
adds Crowsnest to moonraker.conf (update manager)

Signed-off-by: Stephan Wendel <me@stephanwe.de>
This commit is contained in:
Stephan Wendel 2022-05-04 19:06:32 +02:00
parent b8a7046db8
commit c4d4795089
No known key found for this signature in database
GPG Key ID: F465B83ACBA45639
2 changed files with 30 additions and 7 deletions

View File

@ -35,6 +35,9 @@ help:
install: install:
@bash -c tools/install.sh @bash -c tools/install.sh
unattended:
@bash -c tools/install.sh -z
uninstall: uninstall:
@bash -c tools/uninstall.sh @bash -c tools/uninstall.sh

View File

@ -157,12 +157,15 @@ function remove_existing_webcamd {
} }
function install_crowsnest { function install_crowsnest {
local template servicefile logrotatefile bin_path webcamd_bin local bin_path logrotatefile moonraker_conf moonraker_update
local webcamd_bin servicefile template
bin_path="/usr/local/bin" bin_path="/usr/local/bin"
webcamd_bin="${HOME}/crowsnest/webcamd" webcamd_bin="${HOME}/crowsnest/webcamd"
template="${PWD}/sample_configs/${CROWSNEST_DEFAULT_CONF}" template="${PWD}/sample_configs/${CROWSNEST_DEFAULT_CONF}"
servicefile="${PWD}/file_templates/webcamd.service" servicefile="${PWD}/file_templates/webcamd.service"
logrotatefile="${HOME}/crowsnest/file_templates/logrotate_webcamd" logrotatefile="${HOME}/crowsnest/file_templates/logrotate_webcamd"
moonraker_conf="${HOME}/klipper_config/moonraker.conf"
moonraker_update="${PWD}/file_templates/moonraker_update.txt"
echo -e "\nInstall webcamd Service ..." echo -e "\nInstall webcamd Service ..."
## Install Dependencies ## Install Dependencies
echo -e "Installing 'crowsnest' Dependencies ..." echo -e "Installing 'crowsnest' Dependencies ..."
@ -198,12 +201,19 @@ function install_crowsnest {
sudo sed -i 's|pi|'"${BASE_USER}"'|g' /etc/logrotate.d/webcamd sudo sed -i 's|pi|'"${BASE_USER}"'|g' /etc/logrotate.d/webcamd
fi fi
echo -e "Linking logrotate file ... [OK]\r" echo -e "Linking logrotate file ... [OK]\r"
if [ "${UNATTENDED}" == "false" ]; then
echo -en "Reload systemd to enable new deamon ...\r" echo -en "Reload systemd to enable new deamon ...\r"
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]"
echo -en "Enable webcamd.service on boot ...\r" echo -en "Enable webcamd.service on boot ...\r"
sudo systemctl enable webcamd.service sudo systemctl enable webcamd.service
echo -e "Enable webcamd.service on boot ... [OK]\r" echo -e "Enable webcamd.service on boot ... [OK]\r"
fi
if [ "${UNATTENDED}" == "true" ]; then
echo -en "Adding Crowsnest Update Manager entry to moonraker.conf ...\r"
cat "${moonraker_update}" >> "${moonraker_conf}"
echo -e "Adding Crowsnest Update Manager entry to moonraker.conf ... [OK]"
fi
echo -en "Add User ${BASE_USER} to group 'video' ...\r" echo -en "Add User ${BASE_USER} to group 'video' ...\r"
if [ "$(groups | grep -c video)" == "0" ]; then if [ "$(groups | grep -c video)" == "0" ]; then
sudo usermod -aG video "${BASE_USER}" > /dev/null sudo usermod -aG video "${BASE_USER}" > /dev/null
@ -248,6 +258,16 @@ function install_raspicam_fix {
} }
#### MAIN #### MAIN
while getopts "z" arg; do
case ${arg} in
z)
UNATTENDED="true"
;;
*)
UNATTENDED="false"
;;
esac
done
install_cleanup_trap install_cleanup_trap
import_config import_config
welcome_msg welcome_msg