Skip to content

Commit

Permalink
Update Mopidy installer for Mopidy 3/Python 3
Browse files Browse the repository at this point in the history
Note: At time of publishing Iris 3.44.0 is not available on pip, so Iris (3.43.0) will fail to start with Mopidy 3.x

- Drop specific package versions, so we don't have to continually maintain this install script. Not much point holding versions, since pypi packages could be updated and end up incompatible with our older held ones.
- Install python3 versions of dependencies
- Make sure apt unholds mopidy and mopidy-spotify to correct previous installations
- Run an --upgrade install on mopidy-iris so this script can- sort of- be used as an upgrader
- Divine Iris's system.sh location using pkg_resources and *always* update the sudoers file
  • Loading branch information
Gadgetoid committed Jan 30, 2020
1 parent d36ddbf commit 0f50e9f
Showing 1 changed file with 18 additions and 14 deletions.
32 changes: 18 additions & 14 deletions mopidy/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,9 @@
DATESTAMP=`date "+%Y-%m-%d-%H-%M-%S"`
MOPIDY_CONFIG="/etc/mopidy/mopidy.conf"
MOPIDY_SUDOERS="/etc/sudoers.d/010_mopidy-nopasswd"
MOPIDY_SYSTEM_SH="/usr/local/lib/python2.7/dist-packages/mopidy_iris/system.sh"
EXISTING_CONFIG=false
PYTHON_MAJOR_VERSION=2
MOPIDY_VERSION=2.3.1-1
MOPIDY_SPOTIFY_VERSION=3.1.0-0mopidy1
PIP_BIN=pip
PYTHON_MAJOR_VERSION=3
PIP_BIN=pip3

function add_to_config_text {
CONFIG_LINE="$1"
Expand All @@ -35,7 +32,7 @@ warning() {
# Update apt and install dependencies
inform "Updating apt and installing dependencies"
apt update
apt install -y python-rpi.gpio python-spidev python-pip python-pil python-numpy
apt install -y python3-rpi.gpio python3-spidev python3-pip python3-pil python3-numpy
echo

# Verify python version via pip
Expand Down Expand Up @@ -93,22 +90,29 @@ fi

# Install Mopidy and core plugins for Spotify
inform "Installing mopidy packages"
apt install -y --allow-downgrades mopidy=$MOPIDY_VERSION mopidy-spotify=$MOPIDY_SPOTIFY_VERSION
apt-mark hold mopidy mopidy-spotify
apt-mark unhold mopidy mopidy-spotify
apt install -y mopidy mopidy-spotify
echo

# Install Mopidy Iris web UI
inform "Installing Iris web UI for Mopidy"
$PIP_BIN install mopidy-iris
$PIP_BIN install --upgrade mopidy-iris
echo

# Allow Iris to run its system.sh script for https://github.com/pimoroni/pirate-audio/issues/3
# This script backs Iris UI buttons for local scan and server restart.
if [ ! -f "$MOPIDY_SUDOERS" ]; then
inform "Adding $MOPIDY_SYSTEM_SH to $MOPIDY_SUDOERS"
echo "mopidy ALL=NOPASSWD: $MOPIDY_SYSTEM_SH" > $MOPIDY_SUDOERS
echo
fi

# Get location of Iris's system.sh
MOPIDY_SYSTEM_SH=`python$PYTHON_MAJOR_VERSION - <<EOF
import pkg_resources
distribution = pkg_resources.get_distribution('mopidy_iris')
print(f"{distribution.location}/mopidy_iris/system.sh")
EOF`
# Add it to sudoers
inform "Adding $MOPIDY_SYSTEM_SH to $MOPIDY_SUDOERS"
echo "mopidy ALL=NOPASSWD: $MOPIDY_SYSTEM_SH" > $MOPIDY_SUDOERS
echo
# Install support plugins for Pirate Audio
inform "Installing Pirate Audio plugins..."
Expand Down

0 comments on commit 0f50e9f

Please sign in to comment.