Created
August 26, 2016 12:40
-
-
Save jarrettgilliam/c1c7851a44783078202a3da612e1a48a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# This script is to facilitate installing/upgrading | |
# `plexmediaserver` on the ODROID-XU4 platform. | |
# Pass the Synology/ARMV7 package as the first argument | |
# | |
# Credit to youtuber femtronic.com for most of this. | |
# https://www.youtube.com/watch?v=hcCRfbzlhUo | |
# failure function | |
function failure() { | |
echo "Failed!" | |
cd "$oldpwd" | |
rm -rf "$tempdir" | |
exit 1 | |
} | |
# Check input | |
if [ -z "$1" ]; then | |
echo "Error: The Synology/ARMV7 package was not specified" | |
exit 1 | |
elif [ ! -f "$1" ]; then | |
echo "Error: The specified Synology/ARMV7 package does not exist" | |
exit 1 | |
elif [ "$(echo "$1" | egrep -ci '^PlexMediaServer-.*\.spk$')" -ne 1 ]; then | |
echo -n "Warning: the Synology/ARMV7 package name doesn't look right. " | |
echo "Looking for 'PlexMediaServer-*.spk'" | |
echo -n "Continue? " | |
read response | |
if [ "${response:0:1}" != 'Y' -a \ | |
"${response:0:1}" != 'y' ]; then | |
exit 1 | |
fi | |
fi | |
# Variables | |
oldpwd="$(pwd)" | |
tempdir="/tmp/odroid-plex/" | |
package="$1" | |
# Make sure some software is installed | |
echo -n "Installing libexpat1 and fakeroot..." | |
sudo apt-get update >/dev/null 2>&1 || failure | |
sudo apt-get install -y libexpat1 fakeroot >/dev/null 2>&1 || failure | |
echo "Done!" | |
# Copy package and change directories | |
echo -n "Moving to a temporary directory..." | |
rm -rf "$tempdir" || failure | |
mkdir -p "$tempdir" || failure | |
cp "$package" "$tempdir" || failure | |
cd "$tempdir" | |
echo "Done!" | |
# Get skeleton | |
echo -n "Downloading a skeleton deb package..." | |
wget --quiet 'http://www.dev2day.de/skeleton.tgz' || failure | |
tar -xzf "skeleton.tgz" || failure | |
echo "Done!" | |
# Prepare for *.deb package creation | |
echo -n "Preparing to package plexmediaserver..." | |
tar -xf "$package" -C skeleton/usr/lib/plexmediaserver/ || failure | |
rm -rf skeleton/usr/lib/plexmediaserver/dsm_config | |
find skeleton/usr/lib/plexmediaserver/ -iname "*.so*" -exec chmod 644 {} \; | |
cd "$tempdir/skeleton/lib" | |
rm ld-linux.so.3 || failure | |
ln -s /lib/arm-linux-gnueabihf/ld-2.*.so ld-linux.so.3 || failure | |
cd "$tempdir/skeleton/usr/lib/plexmediaserver" | |
tar -xf package.tgz || failure | |
rm package.tgz | |
touch start.sh | |
cd "$tempdir" | |
echo "Done!" | |
# Create and install the *.deb package | |
echo -n "Packaging plexmediaserver..." | |
fakeroot dpkg-deb --build skeleton ./ >/dev/null || failure | |
echo "Done!" | |
echo "Installing plexmediaserver..." | |
sudo dpkg -i plexmediaserver_*.deb || failure | |
echo "Done!" | |
# extra clean up and configuration steps | |
echo -n "Cleaning up..." | |
cp plexmediaserver_*.deb "$oldpwd" || failure | |
cd "$oldpwd" | |
rm -rf "$tempdir" || failure | |
echo "Done!" | |
# Restart plex | |
echo -n "Restarting plexmediaserver..." | |
sudo service plexmediaserver restart || failure | |
echo "Done!" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
wget http://dev2day.de/skeleton.tgz fails