Skip to content

Commit

Permalink
harmonize log output
Browse files Browse the repository at this point in the history
  • Loading branch information
AlvinSchiller committed Nov 20, 2023
1 parent 0e2e1c5 commit 125d689
Show file tree
Hide file tree
Showing 10 changed files with 40 additions and 35 deletions.
4 changes: 2 additions & 2 deletions installation/includes/02_helpers.sh
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@ _download_file_from_google_drive() {

print_verify_installation() {
echo ""
echo "---------------------------------------------------------"
echo "Check installation"
echo " -------------------------------------------------------"
echo " Check installation"
echo ""
}

Expand Down
4 changes: 3 additions & 1 deletion installation/install-jukebox.sh
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,8 @@ Check install log for details:" | tee /dev/fd/3
}

_download_jukebox_source() {
echo -e "\n\n#########################################################"
echo -e "\n\n"
echo "#########################################################"
echo "Downloading Phoniebox software from Github ..." 1>&3
echo "Download Source: ${GIT_URL}/${GIT_BRANCH}" | tee /dev/fd/3

Expand All @@ -136,6 +137,7 @@ _download_jukebox_source() {
fi
mv "$git_repo_download" "$GIT_REPO_NAME"
echo -e "\nDONE: Downloading Phoniebox software from Github"
echo "#########################################################"
}

_load_sources() {
Expand Down
8 changes: 4 additions & 4 deletions installation/routines/set_raspi_config.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,22 +13,22 @@ _run_set_raspi_config() {
# Source: https://raspberrypi.stackexchange.com/a/66939

# Autologin
echo " * Enable Autologin for user"
echo " Enable Autologin for user"
sudo raspi-config nonint do_boot_behaviour B2

# Wait for network at boot
# echo " * Enable 'Wait for network at boot'"
# echo " Enable 'Wait for network at boot'"
# sudo raspi-config nonint do_boot_wait 1

# power management of wifi: switch off to avoid disconnecting
echo " * Disable Wifi power management to avoid disconnecting"
echo " Disable Wifi power management to avoid disconnecting"
sudo iwconfig wlan0 power off

# On-board audio
if [[ $(_get_onboard_audio) -eq 1 ]]; then
DISABLE_ONBOARD_AUDIO=${DISABLE_ONBOARD_AUDIO:-false}
if [[ $DISABLE_ONBOARD_AUDIO = true ]]; then
echo " * Disable on-chip BCM audio"
echo " Disable on-chip BCM audio"
echo " Backup ${RPI_BOOT_CONFIG_FILE} --> ${DISABLE_ONBOARD_AUDIO_BACKUP}"
sudo cp "${RPI_BOOT_CONFIG_FILE}" "${DISABLE_ONBOARD_AUDIO_BACKUP}"
sudo sed -i "s/^\(dtparam=\([^,]*,\)*\)audio=\(on\|true\|yes\|1\)\(.*\)/\1audio=off\4/g" "${RPI_BOOT_CONFIG_FILE}"
Expand Down
2 changes: 1 addition & 1 deletion installation/routines/set_ssh_qos.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ set_ssh_qos() {
if [ "$DISABLE_SSH_QOS" == true ] ; then
# The latest version of SSH installed on the Raspberry Pi 3 uses QoS headers, which disagrees with some
# routers and other hardware. This causes immense delays when remotely accessing the RPi over ssh.
echo " * Set SSH QoS to best effort"
echo " Set SSH QoS to best effort"
echo -e "IPQoS 0x00 0x00\n" | sudo tee -a /etc/ssh/sshd_config
echo -e "IPQoS 0x00 0x00\n" | sudo tee -a /etc/ssh/ssh_config
fi
Expand Down
2 changes: 1 addition & 1 deletion installation/routines/setup_git.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ GIT_ABORT_MSG="Aborting dir to git repo conversion.
Your directory content is untouched, you simply cannot use git for updating / developing"

_git_install_os_dependencies() {
echo "Install Git dependencies"
echo " Install Git dependencies"
sudo apt-get -y update; sudo apt-get -y install \
git \
--no-install-recommends \
Expand Down
14 changes: 7 additions & 7 deletions installation/routines/setup_jukebox_core.sh
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ echo " --------------------------------------------------------------------

# Functions
_jukebox_core_install_os_dependencies() {
echo " Install Jukebox OS dependencies"
echo " Install Jukebox OS dependencies" | tee /dev/fd/3
sudo apt-get -y update && sudo apt-get -y install \
at \
alsa-utils \
Expand All @@ -38,7 +38,7 @@ _jukebox_core_install_os_dependencies() {
}

_jukebox_core_install_python_requirements() {
echo " Install Python requirements"
echo " Install Python requirements" | tee /dev/fd/3

cd "${INSTALLATION_PATH}" || exit_on_error

Expand All @@ -50,7 +50,7 @@ _jukebox_core_install_python_requirements() {
}

_jukebox_core_configure_pulseaudio() {
echo "Copy PulseAudio configuration"
echo " Copy PulseAudio configuration" | tee /dev/fd/3
mkdir -p $(dirname "$JUKEBOX_PULSE_CONFIG")
cp -f "${INSTALLATION_PATH}/resources/default-settings/pulseaudio.default.pa" "${JUKEBOX_PULSE_CONFIG}"
}
Expand Down Expand Up @@ -90,7 +90,7 @@ _jukebox_core_build_and_install_pyzmq() {
# Sources:
# https://pyzmq.readthedocs.io/en/latest/howto/draft.html
# https://github.com/MonsieurV/ZeroMQ-RPi/blob/master/README.md
echo " Build and install pyzmq with WebSockets Support"
echo " Build and install pyzmq with WebSockets Support" | tee /dev/fd/3

if ! pip list | grep -F pyzmq >> /dev/null; then
# Download pre-compiled libzmq from Google Drive because RPi has trouble compiling it
Expand All @@ -115,18 +115,18 @@ _jukebox_core_build_and_install_pyzmq() {
ZMQ_PREFIX="${ZMQ_PREFIX}" ZMQ_DRAFT_API=1 \
pip install --no-cache-dir --no-binary "pyzmq" --pre pyzmq
else
echo " Skipping. pyzmq already installed"
echo " Skipping. pyzmq already installed" | tee /dev/fd/3
fi
}

_jukebox_core_install_settings() {
echo " Register Jukebox settings"
echo " Register Jukebox settings" | tee /dev/fd/3
cp -f "${INSTALLATION_PATH}/resources/default-settings/jukebox.default.yaml" "${SETTINGS_PATH}/jukebox.yaml"
cp -f "${INSTALLATION_PATH}/resources/default-settings/logger.default.yaml" "${SETTINGS_PATH}/logger.yaml"
}

_jukebox_core_register_as_service() {
echo " Register Jukebox Core user service"
echo " Register Jukebox Core user service" | tee /dev/fd/3

sudo cp -f "${INSTALLATION_PATH}/resources/default-services/jukebox-daemon.service" "${JUKEBOX_SERVICE_NAME}"
sudo sed -i "s|%%INSTALLATION_PATH%%|${INSTALLATION_PATH}|g" "${JUKEBOX_SERVICE_NAME}"
Expand Down
2 changes: 1 addition & 1 deletion installation/routines/setup_jukebox_webapp.sh
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ _jukebox_webapp_install_node() {
# TODO: Avoid building the app locally
# Instead implement a Github Action that prebuilds on commititung a git tag
_jukebox_webapp_build() {
echo " Building web application"
echo " Building web application" | tee /dev/fd/3
cd "${INSTALLATION_PATH}/src/webapp" || exit_on_error
npm ci --prefer-offline --no-audit --production
rm -rf build
Expand Down
2 changes: 2 additions & 0 deletions installation/routines/setup_kiosk_mode.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ KIOSK_MODE_CHROMIUM_CUSTOM_DISABLE_UPDATE_CHECK='/etc/chromium-browser/customiza
KIOSK_MODE_CHROMIUM_FLAG_UPDATE_INTERVAL='--check-for-update-interval=31536000'

_kiosk_mode_install_os_dependencies() {
echo " Install Kiosk Mode dependencies" | tee /dev/fd/3
# Resource:
# https://blog.r0b.io/post/minimal-rpi-kiosk/
sudo apt-get -qq -y install --no-install-recommends \
Expand All @@ -18,6 +19,7 @@ _kiosk_mode_install_os_dependencies() {
}

_kiosk_mode_set_autostart() {
echo " Configure Kiosk Mode" | tee /dev/fd/3
local _DISPLAY='$DISPLAY'
local _XDG_VTNR='$XDG_VTNR'

Expand Down
30 changes: 15 additions & 15 deletions installation/routines/setup_mpd.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@ AUDIOFOLDERS_PATH="${SHARED_PATH}/audiofolders"
PLAYLISTS_PATH="${SHARED_PATH}/playlists"

_mpd_install_os_dependencies() {
echo " Install MPD OS dependencies"
sudo apt-get -y update
echo "Install MPD OS dependencies"

echo "Note: Installing MPD might cause a message: 'Job failed. See journalctl -xe for details'"
echo "It can be ignored! It's an artefact of the MPD installation - nothing we can do about it."
sudo apt-get -y install \
Expand All @@ -17,6 +18,13 @@ _mpd_install_os_dependencies() {
}

_mpd_configure() {
echo " Configure MPD as user local service" | tee /dev/fd/3

# Make sure system-wide mpd is disabled
sudo systemctl stop mpd.socket
sudo systemctl stop mpd.service
sudo systemctl disable mpd.socket
sudo systemctl disable mpd.service
# MPD will be setup as user process (rather than a system-wide process)
mkdir -p $(dirname "$MPD_CONF_PATH")

Expand All @@ -25,6 +33,11 @@ _mpd_configure() {
# Prepare new mpd.conf
sed -i 's|%%JUKEBOX_AUDIOFOLDERS_PATH%%|'"$AUDIOFOLDERS_PATH"'|' "${MPD_CONF_PATH}"
sed -i 's|%%JUKEBOX_PLAYLISTS_PATH%%|'"$PLAYLISTS_PATH"'|' "${MPD_CONF_PATH}"

# Prepare user-service MPD to be started at next boot
systemctl --user daemon-reload
systemctl --user enable mpd.socket
systemctl --user enable mpd.service
}

_mpd_check() {
Expand All @@ -45,23 +58,10 @@ _mpd_check() {
}

_run_setup_mpd() {
# Install/update only if enabled: do not stuff up any existing configuration
if [[ $ENABLE_MPD_OVERWRITE_INSTALL == true ]] ; then

# Install/update only if enabled: do not stuff up any existing configuration
_mpd_install_os_dependencies

# Make sure system-wide mpd is disabled
echo "Configure MPD as user local service" | tee /dev/fd/3
sudo systemctl stop mpd.socket
sudo systemctl stop mpd.service
sudo systemctl disable mpd.socket
sudo systemctl disable mpd.service
_mpd_configure
# Prepare user-service MPD to be started at next boot
systemctl --user daemon-reload
systemctl --user enable mpd.socket
systemctl --user enable mpd.service

_mpd_check
fi
}
Expand Down
7 changes: 4 additions & 3 deletions installation/routines/setup_samba.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ SMB_CONF="/etc/samba/smb.conf"
SMB_CONF_HEADER="## Jukebox Samba Config"

_samba_install_os_dependencies() {
echo "Install Samba Core dependencies"
echo " Install Samba Core dependencies"
sudo apt-get -qq -y update; sudo apt-get -qq -y install \
samba samba-common-bin \
--no-install-recommends \
Expand All @@ -14,12 +14,13 @@ _samba_install_os_dependencies() {
}

_samba_set_user() {
echo " Configure Samba" | tee /dev/fd/3
local SMB_USER="pi"
local SMB_PASSWD="raspberry"

# Samba has not been configured
if grep -q "$SMB_CONF_HEADER" "$SMB_CONF"; then
echo " Skipping. Already set up!" | tee /dev/fd/3
echo " Skipping. Already set up!" | tee /dev/fd/3
else
# Create Samba user
(echo "${SMB_PASSWD}"; echo "${SMB_PASSWD}") | sudo smbpasswd -s -a $SMB_USER
Expand Down Expand Up @@ -66,6 +67,6 @@ _run_setup_samba() {

setup_samba() {
if [ "$ENABLE_SAMBA" == true ] ; then
run_with_log_frame _run_setup_samba "Install Samba and configure user"
run_with_log_frame _run_setup_samba "Install Samba"
fi
}

0 comments on commit 125d689

Please sign in to comment.