Skip to content

Commit

Permalink
Integrate functions library (#2)
Browse files Browse the repository at this point in the history
  • Loading branch information
rmens authored Aug 10, 2024
1 parent 774b861 commit 30db971
Showing 1 changed file with 67 additions and 30 deletions.
97 changes: 67 additions & 30 deletions install.sh
Original file line number Diff line number Diff line change
@@ -1,35 +1,72 @@
#!/bin/bash
#!/usr/bin/env bash

# Variables
# Variables (Change these)
WALLPAPER_URL="https://raw.githubusercontent.com/oszuidwest/windows10-baseline/main/assets/ZWTV-wallpaper.png"
CHROME_URL="https://teksttv.zuidwesttv.nl/"

# Update package list
sudo apt update

# Install Necessary Packages
PACKAGES=(
xserver-xorg
x11-xserver-utils
xinit
openbox
unclutter
chromium-browser
feh
ttf-mscorefonts-installer
fonts-crosextra-carlito
fonts-crosextra-caladea
realvnc-vnc-server
)

for PACKAGE in "${PACKAGES[@]}"; do
echo "Installing $PACKAGE..."
if ! sudo apt install --no-install-recommends -y "$PACKAGE"; then
echo "Error installing $PACKAGE"
exit 1
fi
done
# Set-up the functions library
FUNCTIONS_LIB_PATH="/tmp/functions.sh"
FUNCTIONS_LIB_URL="https://raw.githubusercontent.com/oszuidwest/bash-functions/main/common-functions.sh"

# General Raspberry Pi configuration (might be used later but we're not using this so keep the linter happy)
#CONFIG_FILE_PATHS=("/boot/firmware/config.txt" "/boot/config.txt")
#FIRST_IP=$(hostname -I | awk '{print $1}')

# Remove old functions library and download the latest version
rm -f "$FUNCTIONS_LIB_PATH"
if ! curl -s -o "$FUNCTIONS_LIB_PATH" "$FUNCTIONS_LIB_URL"; then
echo -e "*** Failed to download functions library. Please check your network connection! ***"
exit 1
fi

# Source the functions file
# shellcheck source=/dev/null
source "$FUNCTIONS_LIB_PATH"

# Set color variables
set_colors

# Check if running as root
check_user_privileges normal

# Check if this is Linux
is_this_linux
is_this_os_64bit

# Check if we are running on a Raspberry Pi 4 or newer
check_rpi_model 4

# Start with a clean terminal
clear

# Banner
cat << "EOF"
______ _ ___ ______ _______ ____ _____ _______ __
|__ / | | |_ _| _ \ \ / / ____/ ___|_ _| |_ _\ \ / /
/ /| | | || || | | \ \ /\ / /| _| \___ \ | | | | \ \ / /
/ /_| |_| || || |_| |\ V V / | |___ ___) || | | | \ V /
/____|\___/|___|____/ \_/\_/ |_____|____/ |_| |_| \_/
EOF

# Greeting
echo -e "${GREEN}⎎ Raspberry Pi Tekst TV set-up${NC}\n\n"
ask_user "DO_UPDATES" "y" "Do you want to perform all OS updates? (y/n)" "y/n"

# Timezone configuration
set_timezone Europe/Amsterdam

# Update OS
if [ "$DO_UPDATES" == "y" ]; then
update_os silent
fi

# Install dependencies
install_packages silent xserver-xorg x11-xserver-utils x11-utils xinit openbox unclutter chromium-browser feh ttf-mscorefonts-installer fonts-crosextra-carlito fonts-crosextra-caladea realvnc-vnc-server

########## REFACTOR ONDERSTAANDE ################
#
#
#
# Setup Fallback Wallpaper
sudo mkdir -p /var/fallback
sudo wget "$WALLPAPER_URL" -O /var/fallback/fallback.png
Expand All @@ -49,7 +86,7 @@ unclutter -idle 0 &
feh --fullscreen /var/fallback/fallback.png &
# Wait for feh to start
sleep 5
sleep 3
# Start Chromium in kiosk mode
chromium-browser --kiosk --noerrdialogs --disable-infobars --disable-session-crashed-bubble \
Expand All @@ -74,9 +111,9 @@ EOF
sudo raspi-config nonint do_boot_behaviour B2
sudo raspi-config nonint do_vnc 0

# Clean Up
# Clean Up justs to be sure
sudo apt autoremove -y

# Reboot System
# Reboot
echo "Configuration complete. The system will now reboot."
sudo reboot

0 comments on commit 30db971

Please sign in to comment.