Hi SweeC
It is a few years ago that I used this. Hope it still works.
Edit
Links to github on page 7 are working
/Edit
plex.conf
Code
PLEX_MEDIA_SERVER_HOME=/storage/.cache/app.plex
PLEX_MEDIA_SERVER_APPLICATION_SUPPORT_DIR=/storage/.config
PLEX_MEDIA_SERVER_MAX_PLUGIN_PROCS=6
PLEX_MEDIA_SERVER_TMPDIR=/tmp
PLEX_MEDIA_SERVER_INFO_VENDOR=`grep ^NAME= /etc/os-release | awk -F= '{print $2}' | tr -d \")`
PLEX_MEDIA_SERVER_INFO_DEVICE=PC
PLEX_MEDIA_SERVER_INFO_MODEL=`uname -m`
PLEX_MEDIA_SERVER_INFO_PLATFORM_VERSION=`grep ^VERSION= /etc/os-release | awk -F= '{print $2}' | tr -d \")`
LD_LIBRARY_PATH=$PLEX_MEDIA_SERVER_HOME/lib
plex-update.sh
Bash
#!/bin/sh
. /storage/.config/plex.conf
LD_LIBRARY_PATH=/usr/lib
curl -s -L https://aur.archlinux.org/cgit/aur.git/plain/PKGBUILD?h=plex-media-server | grep -E '^pkgver|^_pkgsum' > /tmp/.plex_version || PLEX_BADURL=1
if [ -z "$PLEX_BADURL" ]; then
. /tmp/.plex_version
PLEX_VERSION=$pkgver-$_pkgsum
else
PLEX_VERSION=NA
fi
rm -f /tmp/.plex_version
install_plex() {
mkdir -p /tmp/runplex ; cd /tmp/runplex
case `uname -m` in
x86_64)
wget -q https://downloads.plex.tv/plex-media-server-new/$1/redhat/plexmediaserver-$1.x86_64.rpm || exit 1
rpm2cpio plexmediaserver-$1.x86_64.rpm | cpio -di 2>/dev/null
;;
armv7l)
wget -q https://downloads.plex.tv/plex-media-server-new/$1/debian/plexmediaserver_$1_armhf.deb || exit 1
ar -x *.deb
tar xf data.tar.*
;;
esac
mv usr/lib/plexmediaserver $PLEX_MEDIA_SERVER_HOME
echo $PLEX_VERSION > $PLEX_MEDIA_SERVER_HOME/.plex_version
cd ~ ; rm -rf /tmp/runplex
}
if [ ! -x $PLEX_MEDIA_SERVER_HOME ]; then
echo "Plex directory does not exist, installing."
install_plex $PLEX_VERSION
fi
if [ -f $PLEX_MEDIA_SERVER_HOME/.plex_version ]; then
LOCAL_VERSION=`cat $PLEX_MEDIA_SERVER_HOME/.plex_version`
fi
if [ ! $PLEX_VERSION = $LOCAL_VERSION ] && [ ! $PLEX_VERSION = NA ]; then
echo "New version found, updating."
mv $PLEX_MEDIA_SERVER_HOME $PLEX_MEDIA_SERVER_HOME.bak
install_plex $PLEX_VERSION
else
echo "Plex up to date."
fi
Display More
plex.service
Code
[Unit]
Description=Plex Media Server
After=network.target network-online.target
[Service]
Environment=LC_ALL=C
EnvironmentFile=/storage/.config/plex.conf
ExecStartPre=-/usr/bin/plex-update.sh
ExecStart=/storage/.cache/app.plex/Plex\x20Media\x20Server
Type=simple
Restart=on-failure
RestartSec=5
StartLimitInterval=60s
StartLimitBurst=3
[Install]
WantedBy=multi-user.target
Display More
From my notes:
Code
Put plex-update.sh and plex.conf in /storage/.config/
And plex.service in /storage/.config/system.d/
Correct plex.service:
sed -i 's/usr\/bin\/plex-update.sh/storage\/.config\/plex-update.sh/g' /storage/.config/system.d/plex.service
Installation (with additional output of the script):
Code
First Run (this will download and install Plex server, but not run):
# sh -x /storage/.config/plex-update.sh
Startup: