Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Installation 2.0 #2249

Draft
wants to merge 32 commits into
base: future3/develop
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
b713bac
Categorize install options
pabera Jan 9, 2024
3eb53d7
Move code for IVP6 into separate function; allow both enable/disable …
pabera Jan 9, 2024
a36ded9
Change folder location for options
pabera Jan 9, 2024
e99159f
[ipv6] remove unnecessary test
pabera Jan 9, 2024
f7aa58e
refactor: Allow to enable/disable bluetooth
pabera Jan 9, 2024
085ec43
refactor: Allow to enable/disable and set static ip
pabera Jan 10, 2024
5abd1ff
refactor: Keep raspi-config service alive
pabera Jan 10, 2024
04b84de
refactor: Allow to enable/disable and set boot screen
pabera Jan 10, 2024
ba53cbe
fix: Typo in boot_screen.sh
pabera Jan 10, 2024
188d544
Revert "refactor: Keep raspi-config service alive"
pabera Jan 10, 2024
735b699
fix: Add mixing verify_file_does_not_contain_string function
pabera Jan 10, 2024
c99ded4
fix: Do not depend on raspi-config for boot_screen
pabera Jan 10, 2024
8f6000a
Merge branch 'future3/develop' into future3/feature/installation
pabera Jan 16, 2024
22ef685
fix: Typo
pabera Jan 17, 2024
49cf4c5
Merge branch 'future3/develop' into future3/feature/installation
pabera Jan 22, 2024
b89435f
refactor: abstract boot_path function
pabera Jan 22, 2024
8e4ec13
refactor: outsource boot_logs and systemctl_services
pabera Jan 22, 2024
735063f
Remove option 'Disable on-chip audio' in favor of self-service
pabera Jan 23, 2024
334465e
Remove option 'Disable on-chip audio' in favor of self-service
pabera Jan 23, 2024
a1ebeed
rename: optimize_boot_time to optimized_defaults
pabera Jan 23, 2024
9451924
fix: make options scripts executable
pabera Jan 23, 2024
08cfcb7
refactor: introduce optimized defaults, opinionated improvements
pabera Jan 23, 2024
4ed3a9c
refactor: make ssh_qos.sh an option
pabera Jan 23, 2024
c4a7530
fix: remove unnecessary variable
pabera Jan 23, 2024
02b4bf0
fix: remove bluetooth from installation questionaire
pabera Jan 24, 2024
d812fc1
refactor: move former raspi-config changes into optimized_defaults
pabera Jan 24, 2024
26c5143
Merge branch 'future3/develop' into future3/feature/installation
pabera Feb 8, 2024
b55ca41
Merge branch 'future3/develop' into future3/feature/installation
pabera Mar 1, 2024
de693f7
Align new install script with NetworkManager update
pabera Mar 1, 2024
989571d
Do not disable IPv6 automatically in installation. Still keep functio…
pabera Mar 1, 2024
db609d6
Get back some functions from previous commits
pabera Mar 1, 2024
5684365
Delete set_raspi_config file
pabera Mar 2, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions documentation/builders/audio.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,24 @@ Audio outputs run via PulseAudio and the basic configuration should be easy.
There is a [configuration tool](../developers/coreapps.md#Audio),
to setup the configuration for the Jukebox Core App.

### Disable On-Chip audio

If you are planning on using an external sound card (e.g. USB, HifiBerry, PirateAudio, etc), we recommend to disable the on-chip audio. It will make the sound configuration easier.
If you are planning to only use Bluetooth speakers, leave the on-chip audio enabled!

Run the following command to manage the On-chip audio. Make sure you reboot your device afterwards.

```bash
cd ~/RPi-Jukebox-RFID/installation/options
./onboard_sound.sh disable
```

If you like to enable it, use the following command:

```bash
./onboard_sound.sh enable
```

### To set up the audio

1. Follow the setup steps according to your sound card
Expand Down
1 change: 1 addition & 0 deletions installation/includes/00_constants.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ SYSTEMD_USR_PATH="/usr/lib/systemd/user"
VIRTUAL_ENV="${INSTALLATION_PATH}/.venv"
# Do not change this directory! It must match MPDs expectation where to find the user configuration
MPD_CONF_PATH="${HOME}/.config/mpd/mpd.conf"
WEBAPP_NGINX_SITE_DEFAULT_CONF="/etc/nginx/sites-available/default"

# The default upstream user, release branch, and develop branch
# These are used to prepare the repo for developers
Expand Down
6 changes: 0 additions & 6 deletions installation/includes/01_default_config.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,25 +2,19 @@

BUILD_LIBZMQ_WITH_DRAFTS_ON_DEVICE=${BUILD_LIBZMQ_WITH_DRAFTS_ON_DEVICE:-"false"}
ENABLE_STATIC_IP=true
DISABLE_IPv6=true
ENABLE_AUTOHOTSPOT=false
AUTOHOTSPOT_PROFILE="Phoniebox_Hotspot"
AUTOHOTSPOT_SSID="$AUTOHOTSPOT_PROFILE"
AUTOHOTSPOT_PASSWORD="PlayItLoud!"
AUTOHOTSPOT_IP="10.0.0.1"
AUTOHOTSPOT_COUNTRYCODE="DE"
DISABLE_BLUETOOTH=true
DISABLE_SSH_QOS=true
DISABLE_BOOT_SCREEN=true
DISABLE_BOOT_LOGS_PRINT=true
SETUP_MPD=true
ENABLE_MPD_OVERWRITE_INSTALL=true
UPDATE_RASPI_OS=${UPDATE_RASPI_OS:-"true"}
ENABLE_RFID_READER=true
ENABLE_SAMBA=true
ENABLE_WEBAPP=true
ENABLE_KIOSK_MODE=false
DISABLE_ONBOARD_AUDIO=false
# Always try to use GIT with SSH first, and on failure drop down to HTTPS
GIT_USE_SSH=${GIT_USE_SSH:-"true"}

Expand Down
40 changes: 40 additions & 0 deletions installation/includes/02_helpers.sh
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,46 @@ config_file_revert() {
fi
}

_add_options_to_cmdline() {
local options="$1"

local cmdlineFile=$(get_boot_cmdline_path)
if [ ! -s "${cmdlineFile}" ];then
sudo tee "${cmdlineFile}" <<-EOF
${options}
EOF
else
for option in $options
do
if ! grep -qiw "$option" "${cmdlineFile}" ; then
sudo sed -i "s/$/ $option/" "${cmdlineFile}"
fi
done
fi
}

_remove_options_from_cmdline() {
local options="$1"

local cmdlineFile=$(get_boot_cmdline_path)

if [ -s "${cmdlineFile}" ]; then
for option in $options; do
sudo sed -i "/$option/d" "${cmdlineFile}"
done
fi
}

is_package_installed() {
local package_name=$1

if apt list --installed 2>/dev/null | grep -q "$package_name"; then
echo "true"
else
echo "false"
fi
}

### Verify helpers
print_verify_installation() {
log "\n
Expand Down
30 changes: 30 additions & 0 deletions installation/options/bluetooth.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#!/usr/bin/env bash
source ../includes/02_helpers.sh

if [ -z "$1" ] || { [ "$1" != "enable" ] && [ "$1" != "disable" ]; }; then
print_lc "Error: Invalid or no argument provided.
Usage: ./bluetooth.sh <arg>
where <arg> can be 'enable' or 'disable'"
exit 1
fi

arg="$1"

if [ "$arg" = "enable" ]; then
print_lc "Enabling Bluetooth..."
sudo systemctl enable hciuart.service
sudo systemctl enable bluetooth.service
elif [ "$arg" = "disable" ]; then
print_lc "Disabling Bluetooth..."
sudo systemctl disable hciuart.service
sudo systemctl disable bluetooth.service
fi

# Test
if [ "$arg" = "enable" ]; then
verify_optional_service_enablement hciuart.service enabled
verify_optional_service_enablement bluetooth.service enabled
elif [ "$arg" = "disable" ]; then
verify_optional_service_enablement hciuart.service disabled
verify_optional_service_enablement bluetooth.service disabled
fi
34 changes: 34 additions & 0 deletions installation/options/boot_logs.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
#!/usr/bin/env bash
source ../includes/02_helpers.sh

if [ -z "$1" ] || { [ "$1" != "enable" ] && [ "$1" != "disable" ]; }; then
print_lc "Error: Invalid or no argument provided.
Usage: ./boot_logs.sh <arg>
where <arg> can be 'enable' or 'disable'"
exit 1
fi

arg="$1"
boot_cmdline_options="consoleblank=1 logo.nologo quiet loglevel=0 plymouth.enable=0 vt.global_cursor_default=0 plymouth.ignore-serial-consoles splash fastboot noatime nodiratime noram"

if [ "$arg" = "enable" ]; then
print_lc "Enable Boot logs..."
_remove_options_to_cmdline "${boot_cmdline_options}"

elif [ "$arg" = "disable" ]; then
print_lc "Disable Boot logs..."
_add_options_to_cmdline "${boot_cmdline_options}"
fi

# Test
if [ "$arg" = "enable" ]; then
for option in $boot_cmdline_options
do
verify_file_does_not_contain_string $option "${boot_cmdline_path}"
done
elif [ "$arg" = "disable" ]; then
for option in $boot_cmdline_options
do
verify_file_contains_string_once $option "${boot_cmdline_path}"
done
fi
42 changes: 42 additions & 0 deletions installation/options/boot_screen.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
#!/usr/bin/env bash
source ../includes/02_helpers.sh

if [ -z "$1" ] || { [ "$1" != "enable" ] && [ "$1" != "disable" ]; }; then
print_lc "Error: Invalid or no argument provided.
Usage: ./boot_screen.sh <arg>
where <arg> can be 'enable' or 'disable'"
exit 1
fi

arg="$1"
boot_config_path=$(get_boot_config_path)

_enable_boot_screen() {
sudo sed -i 's/^disable_splash=1/disable_splash=0/' "$boot_config_path"
if ! grep -q "^disable_splash" "$boot_config_path"; then
echo "disable_splash=0" | sudo tee -a "$boot_config_path"
fi
}

_disable_boot_screen() {
sudo sed -i 's/^disable_splash=0/disable_splash=1/' "$boot_config_path"
if ! grep -q "^disable_splash" "$boot_config_path"; then
echo "disable_splash=1" | sudo tee -a "$boot_config_path"
fi
}

# Logic
if [ "$arg" = "enable" ]; then
print_lc "Enabling RPi rainbow screen..."
_enable_boot_screen
elif [ "$arg" = "disable" ]; then
print_lc "Disabling RPi rainbow screen..."
_disable_boot_screen
fi

# Tests
if [ "$arg" = "enable" ]; then
verify_file_does_not_contain_string "disable_splash=" "${boot_config_path}"
elif [ "$arg" = "disable" ]; then
verify_file_contains_string_once "disable_splash=1" "${boot_config_path}"
fi
47 changes: 47 additions & 0 deletions installation/options/ipv6.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
#!/usr/bin/env bash
source ../includes/00_constants.sh
source ../includes/02_helpers.sh

if [ -z "$1" ] || { [ "$1" != "enable" ] && [ "$1" != "disable" ]; }; then
print_lc "Error: Invalid or no argument provided.
Usage: ./ipv6.sh <arg>
where <arg> can be 'enable' or 'disable'"
exit 1
fi

arg="$1"
cmdlineFile=$(get_boot_cmdline_path)
OPTIONS_IPV6="ipv6.disable=1"
nginx_is_installed=$(is_package_installed nginx)

if [ "$arg" = "enable" ]; then
print_lc "Enabling IPv6..."
_remove_options_to_cmdline "${OPTIONS_IPV6}"

if [ "$nginx_is_installed" = "true" ]; then
if ! grep -q 'listen \[::\]:80' "${WEBAPP_NGINX_SITE_DEFAULT_CONF}"; then
echo 'listen [::]:80' | sudo tee -a "${WEBAPP_NGINX_SITE_DEFAULT_CONF}" > /dev/null
fi
fi

elif [ "$arg" = "disable" ]; then
print_lc "Disabling IPv6..."
_add_options_to_cmdline "${OPTIONS_IPV6}"

if [ "$nginx_is_installed" = "true" ]; then
sudo sed -i '/listen \[::\]:80/d' "${WEBAPP_NGINX_SITE_DEFAULT_CONF}"
fi
fi

# Test
if [ "$arg" = "enable" ]; then
verify_file_does_not_contain_string "${OPTIONS_IPV6}" "${cmdlineFile}"
if [ "$nginx_is_installed" = "true" ]; then
verify_file_contains_string "listen [::]:80" "${WEBAPP_NGINX_SITE_DEFAULT_CONF}"
fi
elif [ "$arg" = "disable" ]; then
verify_file_contains_string_once "${OPTIONS_IPV6}" "${cmdlineFile}"
if [ "$nginx_is_installed" = "true" ]; then
verify_file_does_not_contain_string "listen [::]:80" "${WEBAPP_NGINX_SITE_DEFAULT_CONF}"
fi
fi
1 change: 1 addition & 0 deletions installation/options/onboard_sound.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#!/usr/bin/env bash
source ../includes/02_helpers.sh

script_name=$(basename "$0")
boot_config_path=$(get_boot_config_path)

Expand Down
35 changes: 35 additions & 0 deletions installation/options/ssh_qos.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
#!/usr/bin/env bash

# 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.

source ../includes/02_helpers.sh

if [ -z "$1" ] || { [ "$1" != "enable" ] && [ "$1" != "disable" ]; }; then
print_lc "Error: Invalid or no argument provided.
Usage: ./ssh_qos.sh <arg>
where <arg> can be 'enable' or 'disable'"
exit 1
fi

arg="$1"

if [ "$arg" = "enable" ]; then
print_lc "Enabling SSH QoS..."
sudo sed -i '/^IPQoS 0x00 0x00/d' /etc/ssh/sshd_config
sudo sed -i '/^IPQoS 0x00 0x00/d' /etc/ssh/ssh_config
elif [ "$arg" = "disable" ]; then
print_lc "Disabling SSH QoS..."
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

# Test
if [ "$arg" = "enable" ]; then
verify_file_does_not_contain_string "IPQoS 0x00 0x00" "/etc/ssh/sshd_config"
verify_file_does_not_contain_string "IPQoS 0x00 0x00" "/etc/ssh/ssh_config"
elif [ "$arg" = "disable" ]; then
verify_file_contains_string_once "IPQoS 0x00 0x00" "/etc/ssh/sshd_config"
verify_file_contains_string_once "IPQoS 0x00 0x00" "/etc/ssh/ssh_config"
fi
Loading
Loading