Skip to content
This repository has been archived by the owner on May 18, 2024. It is now read-only.

Commit

Permalink
merging PR 448
Browse files Browse the repository at this point in the history
  • Loading branch information
riffnshred committed Feb 28, 2024
1 parent e3ac19a commit 4d6c196
Show file tree
Hide file tree
Showing 5 changed files with 558 additions and 65 deletions.
4 changes: 2 additions & 2 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
env-canada
ephem
fastjsonschema>=2.14.4
geocoder>=1.38.1
geocoder>=1.38.1
gpiozero==1.6.2
nhl-api-py>=2.4.0
noaa-sdk>=0.1.18
pyowm>=3.0.0
python-tsl2591==0.2.0
regex>=2020.4.4
RPi.GPIO>=0.7.1
APScheduler==3.10.4
lastversion>=1.1.6
nameparser>=1.0.6
Expand All @@ -19,3 +18,4 @@ cairosvg
tzlocal
rich
diskcache
env-canada>=0.6.1
157 changes: 100 additions & 57 deletions scripts/install.sh
Original file line number Diff line number Diff line change
@@ -1,62 +1,105 @@
#!/bin/bash
#! /bin/bash

# Make script work regardless of where it is run from
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
cd "${DIR}/.." || exit

echo "$(tput setaf 6)Installing required dependencies. This may take some time (10-20 minutes-ish)...$(tput setaf 9)"
#Install all apt requirements using aptfile
sudo scripts/aptfile apt-requirements

#Install all pip3 requirements using the requirements.txt filer
sudo pip3 install -U -r requirements.txt

# Pull submodule and ignore changes from script
git submodule update --init --recursive
git config submodule.matrix.ignore all

echo "$(tput setaf 4)Running rgbmatrix installation...$(tput setaf 9)"

# Recompile the cpp files to build library with newest cython. See https://github.com/hzeller/rpi-rgb-led-matrix/issues/1298

cd submodules/matrix/bindings/python/rgbmatrix/ || exit

# The following lines are no longer necessary
# python3 -m pip install --no-cache-dir cython
# python3 -m cython -2 --cplus *.pyx

cd ../../../ || exit

make build-python PYTHON="$(command -v python3)"
sudo make install-python PYTHON="$(command -v python3)"

cd ../../../ || exit

# Blacklist the snd_bcm2835 sounds module
sudo tee /etc/modprobe.d/blacklist-rgbmatrix.conf <<TEXT1
## Make sure the sound module does not load as it causes issues with the timing for the rgb matrix library
blacklist snd_bcm2835
# The next time the loading of the module is attempted, the /bin/false
# will be executed instead. This will prevent the module from being
# loaded on-demand.
install snd_bcm_2835 /bin/false
TEXT1

# Unload the sound module
sudo modprobe -r snd_bcm2835

# Rebuild module dependacy
sudo depmod -a

sudo sed -i 's/$/ isolcpus=3/' /boot/cmdline.txt

git reset --hard
git fetch origin --prune
git pull

make
echo "If you didn't see any errors above, everything should be installed!"
echo "$(tput bold)$(tput smso)$(tput setaf 2)Installation complete!$(tput sgr0) Play around with the examples in nhl-led-scoreboard/submodules/matrix/bindings/python/samples to make sure your matrix is working."
# Don't run as root user
if [ $(id -u) -eq 0 ]; then
tput bold; echo "$(tput setaf 9)You do not need to run this script using sudo, it will handle sudo as required$(tput setaf 9)" ; tput sgr0
exit 1
fi

deb_ver () {
ver=$(cut -d . -f 1 < /etc/debian_version)
echo $ver
}

deb_name () {
. /etc/os-release; echo "$PRETTY_NAME"
}

py_ver () {
pyver="$(command -p python3 -V | sed 's/Python //g')"
echo $pyver
}

show_virtual_env() {
if [ -n "$VIRTUAL_ENV" ]; then
echo "VENV name: $(basename $VIRTUAL_ENV)"
else
echo "No VENV installed"
fi
}

py_loc () {
pyloc="$(command -v python3)"
echo $pyloc
}

get_model() {
pimodel=$(tr -d '\0' </proc/device-tree/model)
echo $pimodel
}

calc_wt_size() {
# NOTE: it's tempting to redirect stderr to /dev/null, so supress error
# output from tput. However in this case, tput detects neither stdout or
# stderr is a tty and so only gives default 80, 24 values
WT_HEIGHT=18
WT_WIDTH=$(tput cols)

if [ -z "$WT_WIDTH" ] || [ "$WT_WIDTH" -lt 60 ]; then
WT_WIDTH=80
fi
if [ "$WT_WIDTH" -gt 178 ]; then
WT_WIDTH=120
fi
WT_MENU_HEIGHT=$((WT_HEIGHT - 7))
}

do_install() {
scripts/sbtools/sb-init
exit 0
}

do_upgrade() {
scripts/sbtools/sb-upgrade
exit 0
}

do_help() {
whiptail --msgbox "\
This tool provides a straightforward way of doing initial
install of the NHL LED Scoreboard or an Upgrade of an existing installation\
" 20 70 1
return 0
}

calc_wt_size

backtitle="$(get_model) [$(deb_name)] [Python: $(py_loc) V$(py_ver) $(show_virtual_env)]"

while true; do

FUN=$(whiptail --title "NHL LED Scoreboard Install/Upgrade Tool" --backtitle "$backtitle" --menu "Options" $WT_HEIGHT $WT_WIDTH $WT_MENU_HEIGHT --cancel-button Finish --ok-button Select \
"1 New Install" "Use this if this is your first time installing" \
"2 Upgrade" "Use this if you are upgrading" \
"3 Help" "Show help for this tool" \
3>&1 1>&2 2>&3)

RET=$?

if [ $RET -eq 1 ]; then
exit 0
elif [ $RET -eq 0 ]; then
case "$FUN" in
1\ *) do_install ;;
2\ *) do_upgrade ;;
3\ *) do_help ;;
*) whiptail --msgbox "Programmer error: unrecognized option" 20 60 1 ;;
esac || whiptail --msgbox "There was an error running option $FUN" 20 60 1
else
exit 1
fi
done
Loading

0 comments on commit 4d6c196

Please sign in to comment.