Skip to content

Commit

Permalink
Cleanup installation messages (MiczFlor#2109)
Browse files Browse the repository at this point in the history
* cleanup installation messages

use clear for each new option
added headers
use correct urls in finish message
fixed some typos and wording

* fix usage with multiple ip addresses (ipv4/ipv6)

use single call to get all information during installation
show and read out only first ip in webui

* fix typo in translation

* fix order for gateway / interface

* harmonize read answer option

* fix FIN_MESSAGE

* fix line break on OS check
  • Loading branch information
AlvinSchiller authored Nov 18, 2023
1 parent babb237 commit dfb9e93
Show file tree
Hide file tree
Showing 9 changed files with 125 additions and 81 deletions.
2 changes: 1 addition & 1 deletion installation/includes/02_helpers.sh
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ check_os_type() {
local os_type
os_type=$(uname -m)

echo "Checking OS type ... $os_type" | tee /dev/fd/3
echo -e "\nChecking OS type '$os_type'" | tee /dev/fd/3

if [[ $os_type == "armv7l" || $os_type == "armv6l" ]]; then
echo -e " ... OK!\n" | tee /dev/fd/3
Expand Down
12 changes: 7 additions & 5 deletions installation/includes/03_welcome.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,18 @@ Depending on your hardware, this installation might last
around 60 minutes (usually it's faster). It updates OS
packages, installs Phoniebox dependencies and registers
settings. Be patient and don't let your computer go to
sleep. It might disconnect your SSH connection causing the
interruption of the installation process.
sleep. It might disconnect your SSH connection causing
the interruption of the installation process.
Consider starting the installation in a terminal
multiplexer like 'screen' or 'tmux' to avoid this.
By the way, you can follow the installation details here
in a separate SSH session:
cd; tail -f ${INSTALLATION_LOGFILE}
Let's set up your Phoniebox now?! [Y/n]" 1>&3

read -rp "Do you want to install? [Y/n] " response
Let's set up your Phoniebox.
Do you want to start the installation? [Y/n]" 1>&3
read -r response
case "$response" in
[nN][oO]|[nN])
exit
Expand Down
19 changes: 9 additions & 10 deletions installation/includes/05_finish.sh
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
#!/usr/bin/env bash

finish() {
echo -e "
---
local local_hostname=$(hostname)
echo -e "####################### FINISHED ########################
Installation complete!
Expand All @@ -11,14 +11,13 @@ ${FIN_MESSAGE}
In order to start, you need to reboot your Raspberry Pi.
Your SSH connection will disconnect.
After the reboot, open either http://raspberrypi.local
(for Mac / iOS) or http://[IP-ADDRESS] (for Android / Windows)
in a browser to get started. Don't forget to upload files
via Samba.
After the reboot, you can access the WebApp in your browser at
http://${local_hostname}.local or http://${CURRENT_IP_ADDRESS}
Don't forget to upload files.
Do you want to reboot now? [Y/n]" 1>&3

read -rp "Do you want to reboot now? [Y/n] " response
read -r response
case "$response" in
[nN][oO]|[nN])
echo "Reboot aborted" | tee /dev/fd/3
Expand All @@ -41,14 +40,14 @@ Do you want to reboot now? [Y/n]" 1>&3
exit_on_error () {

echo -e "\n****************************************" | tee /dev/fd/3
echo -e "ERROR OCCURRED!
echo "ERROR OCCURRED!
A non-recoverable error occurred.
Check install log for details:" | tee /dev/fd/3
echo "$INSTALLATION_LOGFILE" | tee /dev/fd/3
echo -e "****************************************" | tee /dev/fd/3
echo "****************************************" | tee /dev/fd/3
if [[ -n $1 ]]; then
echo "$1" | tee /dev/fd/3
echo -e "****************************************" | tee /dev/fd/3
echo "****************************************" | tee /dev/fd/3
fi
echo "Abort!"
exit 1
Expand Down
142 changes: 95 additions & 47 deletions installation/routines/customize_options.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,21 @@

_option_static_ip() {
# ENABLE_STATIC_IP
CURRENT_IP_ADDRESS=$(hostname -I)
echo "Would you like to set a static IP (will be ${CURRENT_IP_ADDRESS})?
It'll save a lot of start up time. This can be changed later.
[Y/n] " 1>&3
# Using the dynamically assigned IP address as it is the best guess to be free
# Reference: https://unix.stackexchange.com/a/505385
CURRENT_ROUTE=$(ip route get 8.8.8.8)
CURRENT_GATEWAY=$(echo "${CURRENT_ROUTE}" | awk '{ print $3; exit }')
CURRENT_INTERFACE=$(echo "${CURRENT_ROUTE}" | awk '{ print $5; exit }')
CURRENT_IP_ADDRESS=$(echo "${CURRENT_ROUTE}" | awk '{ print $7; exit }')
clear 1>&3
echo "----------------------- STATIC IP -----------------------
Setting a static IP will save a lot of start up time.
The static adress will be '${CURRENT_IP_ADDRESS}'
from interface '${CURRENT_INTERFACE}'
with the gateway '${CURRENT_GATEWAY}'.
Set a static IP? [Y/n]" 1>&3
read -r response
case "$response" in
[nN][oO]|[nN])
Expand All @@ -19,7 +30,13 @@ It'll save a lot of start up time. This can be changed later.

_option_ipv6() {
# DISABLE_IPv6
echo "Do you want to disable IPv6? [Y/n] " 1>&3
clear 1>&3
echo "------------------------- IP V6 -------------------------
IPv6 is only needed if you intend to use it.
Otherwise it can be disabled.
Do you want to disable IPv6? [Y/n]" 1>&3
read -r response
case "$response" in
[nN][oO]|[nN])
Expand All @@ -33,14 +50,17 @@ _option_ipv6() {

_option_autohotspot() {
# ENABLE_AUTOHOTSPOT
echo "Do you want to enable a WiFi hotspot on demand?
clear 1>&3
echo "---------------------- AUTOHOTSPOT ----------------------
When enabled, this service spins up a WiFi hotspot
when the Phoniebox is unable to connect to a known
WiFi. This way you can still access it.
[y/N] " 1>&3
Do you want to enable an Autohotpot? [y/N]" 1>&3
read -r response
case "$response" in
[yY])
[yY][eE][sS]|[yY])
ENABLE_AUTOHOTSPOT=true
;;
*)
Expand All @@ -51,7 +71,7 @@ WiFi. This way you can still access it.
echo "Do you want to set a custom Password? (default: ${AUTOHOTSPOT_PASSWORD}) [y/N] " 1>&3
read -r response_pw_q
case "$response_pw_q" in
[yY])
[yY][eE][sS]|[yY])
while [ $(echo ${response_pw}|wc -m) -lt 8 ]
do
echo "Please type the new password (at least 8 character)." 1>&3
Expand Down Expand Up @@ -80,9 +100,13 @@ WiFi. This way you can still access it.

_option_bluetooth() {
# DISABLE_BLUETOOTH
echo "Do you want to disable Bluetooth?
Turn off Bluetooth if you do not plan to use it. It saves energy and start up time.
[Y/n] " 1>&3
clear 1>&3
echo "----------------------- BLUETOOTH -----------------------
Turning off Bluetooth will save energy and
start up time, if you do not plan to use it.
Do you want to disable Bluetooth? [Y/n]" 1>&3
read -r response
case "$response" in
[nN][oO]|[nN])
Expand All @@ -96,10 +120,15 @@ Turn off Bluetooth if you do not plan to use it. It saves energy and start up ti

_option_samba() {
# ENABLE_SAMBA
echo "Samba will be installed. It is required to conveniently copy files to
your Phoniebox via a network share. If you don't need it, feel free to skip
the installation. If you are unsure, stick to YES!
[Y/n] " 1>&3
clear 1>&3
echo "------------------------- SAMBA -------------------------
Samba is required to conveniently copy files
to your Phoniebox via a network share.
If you don't need it, feel free to skip the installation.
If you are unsure, stick to YES!
Do you want to install Samba? [Y/n]" 1>&3
read -r response
case "$response" in
[nN][oO]|[nN])
Expand All @@ -114,10 +143,13 @@ the installation. If you are unsure, stick to YES!

_option_webapp() {
# ENABLE_WEBAPP
echo "Would you like to install the web application?
This is only required if you want to use a graphical interface
to manage your Phoniebox!
[Y/n] " 1>&3
clear 1>&3
echo "------------------------ WEBAPP -------------------------
This is only required if you want to use
a graphical interface to manage your Phoniebox!
Would you like to install the web application? [Y/n]" 1>&3
read -r response
case "$response" in
[nN][oO]|[nN])
Expand All @@ -132,14 +164,18 @@ to manage your Phoniebox!

_option_kiosk_mode() {
# ENABLE_KIOSK_MODE
echo "Would you like to enable the Kiosk Mode?
If you have a screen attached to your RPi, this will launch the
web application right after boot. It will only install the necessary
xserver dependencies and not the entire RPi desktop environment.
[y/N] " 1>&3
clear 1>&3
echo "----------------------- KIOSK MODE ----------------------
If you have a screen attached to your RPi,
this will launch the web application right after boot.
It will only install the necessary xserver dependencies
and not the entire RPi desktop environment.
Would you like to enable the Kiosk Mode? [y/N]" 1>&3
read -r response
case "$response" in
[yY])
[yY][eE][sS]|[yY])
ENABLE_KIOSK_MODE=true
;;
*)
Expand All @@ -150,12 +186,16 @@ xserver dependencies and not the entire RPi desktop environment.

_options_update_raspi_os() {
# UPDATE_RASPI_OS
echo "Would you like to update the operating system?
This shall be done eventually, but increases the installation time a lot.
[Y/n] " 1>&3
clear 1>&3
echo "----------------------- UPDATE OS -----------------------
This shall be done eventually,
but increases the installation time a lot.
Would you like to update the operating system? [Y/n]" 1>&3
read -r response
case "$response" in
[nN])
[nN][oO]|[nN])
UPDATE_RASPI_OS=false
;;
*)
Expand All @@ -167,18 +207,25 @@ This shall be done eventually, but increases the installation time a lot.
_option_disable_onboard_audio() {
# Disable BCM on-chip audio (typically Headphones)
# not needed when external sound card is sued
clear 1>&3
echo "--------------------- ON-CHIP AUDIO ---------------------
If you are using an external sound card (e.g. USB,
HifiBerry, PirateAudio, etc), we recommend to disable
the on-chip audio. It will make the ALSA sound
configuration easier.
If you are planning to only use Bluetooth speakers,
leave the on-chip audio enabled!
(This will touch your boot configuration in
${RPI_BOOT_CONFIG_FILE}.
We will do our best not to mess anything up. However,
a backup copy will be written to
${DISABLE_ONBOARD_AUDIO_BACKUP} )
echo -e "Disable Pi's on-chip audio (headphone / jack output)?
If you are using an external sound card (e.g. USB, HifiBerry, PirateAudio, etc),
we recommend to disable the on-chip audio. It will make the ALSA sound configuration easier.
If you are planning to only use Bluetooth speakers, leave the on-chip audio enabled!
(This will touch your boot configuration in ${RPI_BOOT_CONFIG_FILE}.
We will do our best not to mess anything up. However, a backup copy will be written to
${DISABLE_ONBOARD_AUDIO_BACKUP} if things go pear-shaped.)
[y/N] " 1>&3
Disable Pi's on-chip audio (headphone / jack output)? [y/N]" 1>&3
read -r response
case "$response" in
[yY])
[yY][eE][sS]|[yY])
DISABLE_ONBOARD_AUDIO=true
;;
*)
Expand All @@ -196,36 +243,37 @@ _option_webapp_devel_build() {
if [[ "$ENABLE_WEBAPP_PROD_DOWNLOAD" = "release-only" ]]; then
ENABLE_WEBAPP_PROD_DOWNLOAD=false
fi

if [[ "$ENABLE_WEBAPP_PROD_DOWNLOAD" = false ]]; then
echo -e "Your are installing from a non-release branch.
clear 1>&3
echo "--------------------- WEBAPP NODE ---------------------
You are installing from a non-release branch.
This means, you will need to build the web app locally.
For that you'll need Node.
Do you want to install Node? [Y/n] " 1>&3
Do you want to install Node? [Y/n]" 1>&3
read -r response
case "$response" in
[nN])
[nN][oO]|[nN])
ENABLE_INSTALL_NODE=false
;;
*)
;;
esac

# This message will be displayed at the end of the installation process
FIN_MESSAGE="$FIN_MESSAGE\n\nATTENTION: You need to build the web app locally with
FIN_MESSAGE="$FIN_MESSAGE\nATTENTION: You need to build the web app locally with
$ cd ~/RPi-Jukebox-RFID/src/webapp && ./run_rebuild.sh -u
This must be done after reboot, due to memory restrictions.
Read the documentation regarding local Web App builds!"
ENABLE_WEBAPP_PROD_DOWNLOAD=false
fi
fi
}

customize_options() {
echo "Customize Options starts"

_option_static_ip
_option_ipv6
_option_static_ip
_option_autohotspot
_option_bluetooth
_option_disable_onboard_audio
Expand Down
1 change: 1 addition & 0 deletions installation/routines/install.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
install() {
check_os_type
clear 1>&3
customize_options
clear 1>&3
set_raspi_config
Expand Down
19 changes: 5 additions & 14 deletions installation/routines/optimize_boot_time.sh
Original file line number Diff line number Diff line change
Expand Up @@ -40,26 +40,17 @@ _optimize_handle_network_connection() {
echo " Skipping. Already set up!" | tee /dev/fd/3
else
# DHCP has not been configured
# Reference: https://unix.stackexchange.com/a/307790/478030
INTERFACE=$(route | grep '^default' | grep -o '[^ ]*$')

# Reference: https://serverfault.com/a/31179/431930
GATEWAY=$(route -n | grep 'UG[ \t]' | awk '{print $2}')

# Using the dynamically assigned IP address as it is the best guess to be free
# Reference: https://unix.stackexchange.com/a/48254/478030
CURRENT_IP_ADDRESS=$(hostname -I)
echo " * ${INTERFACE} is the default network interface" | tee /dev/fd/3
echo " * ${GATEWAY} is the Router Gateway address" | tee /dev/fd/3
echo " * ${CURRENT_INTERFACE} is the default network interface" | tee /dev/fd/3
echo " * ${CURRENT_GATEWAY} is the Router Gateway address" | tee /dev/fd/3
echo " * Using ${CURRENT_IP_ADDRESS} as the static IP for now" | tee /dev/fd/3

sudo tee -a $DHCP_CONF <<-EOF
## Jukebox DHCP Config
interface ${INTERFACE}
interface ${CURRENT_INTERFACE}
static ip_address=${CURRENT_IP_ADDRESS}/24
static routers=${GATEWAY}
static domain_name_servers=${GATEWAY}
static routers=${CURRENT_GATEWAY}
static domain_name_servers=${CURRENT_GATEWAY}
EOF

Expand Down
6 changes: 3 additions & 3 deletions installation/routines/setup_mpd.sh
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,9 @@ setup_mpd() {
local MPD_EXECUTE_INSTALL=true

if [[ -f ${MPD_CONF_PATH} || -f ${SYSTEMD_USR_PATH}/mpd.service ]]; then
echo " It seems there is a MPD already installed."
echo " Note: It is important that MPD runs as a user service!"
echo " Would you like to overwrite your configuration? [Y/n] " | tee /dev/fd/3
echo "It seems there is a MPD already installed.
Note: It is important that MPD runs as a user service!
Would you like to overwrite your configuration? [Y/n]" 1>&3
read -r response
case "$response" in
[nN][oO]|[nN])
Expand Down
3 changes: 3 additions & 0 deletions src/jukebox/components/hostif/linux/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,9 @@ def get_ip_address():
ip_address = p.stdout.strip().decode()
else:
ip_address = '127.0.0.1'

# only get first if multiple adresses are present (ipv4/ipv6)
ip_address = ip_address.split(' ')[0]
return ip_address


Expand Down
Loading

0 comments on commit dfb9e93

Please sign in to comment.