Skip to content

Commit

Permalink
add check for jukebox core setup
Browse files Browse the repository at this point in the history
  • Loading branch information
AlvinSchiller committed Nov 15, 2023
1 parent 1693d80 commit 9c12249
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 2 deletions.
17 changes: 17 additions & 0 deletions installation/includes/02_helpers.sh
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@ get_args_from_file() {
# Check if all passed packages are installed. Fail on first missing.
verify_apt_packages() {
local packages="$@"
echo "Verify packages are installed: '${packages}'"

if [ -n "${packages}" ]; then
local apt_list_installed=$(apt -qq list --installed 2>/dev/null)
Expand All @@ -132,3 +133,19 @@ verify_apt_packages() {
done
fi
}

# Check if all passed modules are installed. Fail on first missing.
verify_pip_modules() {
local modules="$@"
echo "Verify modulesa are installed: '${packages}'"

if [ -n "${modules}" ]; then
local pip_list_installed=$(pip list 2>/dev/null)
for module in ${modules}
do
if [[ ! $(echo "${pip_list_installed}" | grep -i "${module}") ]]; then
exit_on_error "ERROR: ${module} is not installed"
fi
done
fi
}
29 changes: 27 additions & 2 deletions installation/routines/setup_jukebox_core.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ GD_ID_COMPILED_PYZMQ_ARMV6="1lDsV_pVcXbg6YReHb9AldMkyRZCpc6-n" # https://drive.g
ZMQ_TMP_DIR="libzmq"
ZMQ_PREFIX="/usr/local"

JUKEBOX_PULSE_CONFIG="${HOME_PATH}"/.config/pulse/default.pa

_show_slow_hardware_message() {
echo " --------------------------------------------------------------------
| Your hardware is a little slower so this step will take a while. |
Expand Down Expand Up @@ -37,8 +39,8 @@ _jukebox_core_install_os_dependencies() {

_jukebox_core_configure_pulseaudio() {
echo "Copy PulseAudio configuration"
mkdir -p ~/.config/pulse
cp -f "${INSTALLATION_PATH}/resources/default-settings/pulseaudio.default.pa" ~/.config/pulse/default.pa
mkdir -p $(dirname "$JUKEBOX_PULSE_CONFIG")
cp -f "${INSTALLATION_PATH}/resources/default-settings/pulseaudio.default.pa" "${JUKEBOX_PULSE_CONFIG}"
}

_jukebox_core_build_libzmq_with_drafts() {
Expand Down Expand Up @@ -126,6 +128,28 @@ _jukebox_core_register_as_service() {
systemctl --user enable jukebox-daemon.service
}

_jukebox_core_check () {
echo "Check Jukebox Core Installation" | tee /dev/fd/3
verify_apt_packages at \
alsa-utils \
python3 python3-dev python3-pip python3-setuptools \
python3-rpi.gpio python3-gpiozero \
espeak ffmpeg mpg123 \
pulseaudio pulseaudio-module-bluetooth pulseaudio-utils caps \

verify_chmod_chown 755 "${CURRENT_USER}" "${CURRENT_USER_GROUP}" "${JUKEBOX_PULSE_CONFIG}"

local pip_modules=$(get_args_from_file "${INSTALLATION_PATH}/requirements.txt")
verify_pip_modules pyzmq $pip_modules

verify_chmod_chown 644 "${CURRENT_USER}" "${CURRENT_USER_GROUP}" "${SETTINGS_PATH}/jukebox.yaml"
verify_chmod_chown 644 "${CURRENT_USER}" "${CURRENT_USER_GROUP}" "${SETTINGS_PATH}/logger.yaml"

verify_chmod_chown 644 root root "${SYSTEMD_USR_PATH}/jukebox-daemon.service"

check_service_enablement --user jukebox-daemon.service enabled
}

setup_jukebox_core() {
echo "Install Jukebox Core" | tee /dev/fd/3

Expand All @@ -135,6 +159,7 @@ setup_jukebox_core() {
_jukebox_core_build_and_install_pyzmq
_jukebox_core_install_settings
_jukebox_core_register_as_service
_jukebox_core_check

echo "DONE: setup_jukebox_core"
}

0 comments on commit 9c12249

Please sign in to comment.