From fa99d61bf0c063ad51b341128789c1dce11f30f9 Mon Sep 17 00:00:00 2001
From: Britney Fransen <brfransen@gmail.com>
Date: Wed, 6 Jul 2016 17:00:24 +0000
Subject: plex-media-server: update to 1.0.0.2261

---
 abs/extra/plex-media-server/MKPKG                  |  3 --
 abs/extra/plex-media-server/PKGBUILD               | 30 ++++++++--------
 abs/extra/plex-media-server/__changelog            |  2 +-
 .../plex-media-server/plex-media-server.install    | 41 +++-------------------
 abs/extra/plex-media-server/plex.sysusers          |  2 ++
 .../plex-media-server/plexmediaserver.service      |  1 +
 6 files changed, 23 insertions(+), 56 deletions(-)
 delete mode 100644 abs/extra/plex-media-server/MKPKG
 create mode 100644 abs/extra/plex-media-server/plex.sysusers

diff --git a/abs/extra/plex-media-server/MKPKG b/abs/extra/plex-media-server/MKPKG
deleted file mode 100644
index 01a47b4..0000000
--- a/abs/extra/plex-media-server/MKPKG
+++ /dev/null
@@ -1,3 +0,0 @@
-pkgname=('plex-media-server')
-
-# vim: ts=2 sw=2 et:
diff --git a/abs/extra/plex-media-server/PKGBUILD b/abs/extra/plex-media-server/PKGBUILD
index 42f7f3d..29d2704 100644
--- a/abs/extra/plex-media-server/PKGBUILD
+++ b/abs/extra/plex-media-server/PKGBUILD
@@ -7,9 +7,9 @@
 # Contributor: Praekon <praekon@googlemail.com>
 
 pkgname=plex-media-server
-pkgver=0.9.16.6.1993
-_pkgsum=5089475
-pkgrel=1
+pkgver=1.0.0.2261
+_pkgsum=a17e99e
+pkgrel=2
 pkgdesc='Plex Media Server'
 arch=('x86_64')
 url='https://plex.tv/'
@@ -17,21 +17,21 @@ license=('custom')
 depends=('systemd')
 makedepends_i686=('prelink')
 makedepends_x86_64=('prelink')
-replaces=('plexmediaserver')
-conflicts=('plexmediaserver' 'plexmediaserver-plexpass')
+provides=('plex-media-server')
+conflicts=('plex-media-server-plexpass')
 backup=('etc/conf.d/plexmediaserver')
 install='plex-media-server.install'
 source=('plexmediaserver.conf.d'
         'plexmediaserver.service'
+        'plex.sysusers'
         'terms.txt'
         'plexmediascanner.sh')
-#source_arm=("https://downloads.plex.tv/plex-media-server/${pkgver}-${_pkgsum}/PlexMediaServer-${pkgver}-${_pkgsum}-arm.spk")
 #source_armv7h=("https://downloads.plex.tv/plex-media-server/${pkgver}-${_pkgsum}/PlexMediaServer-${pkgver}-${_pkgsum}-arm7.spk")
 #source_i686=("https://downloads.plex.tv/plex-media-server/${pkgver}-${_pkgsum}/plexmediaserver-${pkgver}-${_pkgsum}.i386.rpm")
 source_x86_64=("https://downloads.plex.tv/plex-media-server/${pkgver}-${_pkgsum}/plexmediaserver-${pkgver}-${_pkgsum}.x86_64.rpm")
-#sha256sums_arm=('77792714279505e8b3fda046f841d0ed0c9bcee181678ffff27c49bde9e43e27')
-#sha256sums_armv7h=('e23b3248cc599c8f99213e213df48edef0d44afd5ef1f32404ccd5c8ee84560c')
-#sha256sums_i686=('73cdaa48714c95d9cae7f8411f50b4632e0a6f425ded6bd681d0d5008dea9397')
+#sha256sums_armv7h=('1a7b7610eb7f1857cece6290d3786022cef337cee062ee5b984ec94761bb0c6e')
+#sha256sums_i686=('2d2a71a50b6a95fc91c64c01ea2ec2bba2aedd80068481c441106551ed7eeae9')
+#sha256sums_x86_64=('99821d4795a50e5ce9ceb7947d21c7418b328d014a00b6390e4a2913ed189192')
 
 prepare() {
 
@@ -48,18 +48,18 @@ package() {
   cp -dr --no-preserve='ownership' usr/lib/plexmediaserver "${pkgdir}"/opt/
   install -m 644 plexmediaserver.service "${pkgdir}"/usr/lib/systemd/system/
   install -m 644 plexmediaserver.conf.d "${pkgdir}"/etc/conf.d/plexmediaserver
+  install -Dm 644 "$srcdir/plex.sysusers" "$pkgdir/usr/lib/sysusers.d/plex.conf"
 
   install -m 755 -D plexmediascanner.sh "${pkgdir}"/usr/LH/bin/plexmediascanner.sh
-  #install -dm 755 "${pkgdir}"/var/lib/plex
-  #chown 421:421 -R "${pkgdir}"/var/lib/plex
 
-  install -dm 755 "${pkgdir}"/usr/share/licenses/plex-media-server
-  install -m 644 terms.txt "${pkgdir}"/usr/share/licenses/plex-media-server/
+  install -dm 755 "${pkgdir}"/usr/share/licenses/${pkgname}
+  install -m 644 terms.txt "${pkgdir}"/usr/share/licenses/${pkgname}/
 }
 
 # vim: ts=2 sw=2 et:
 md5sums=('dfd6778f5c0d3d64c2c3a71dca02b7cc'
-         '34268b981e3b8c833a0e2270429232a6'
+         '3f39ee0e8b1ebb1c7ca714f67fa88641'
+         '97241861f2c0b7c82d1945a6c5de8e35'
          'bd703bc750b989a27edd590eb8c8e9d7'
          '506ec15815bba749a743780edd2323c8')
-md5sums_x86_64=('20e6e297df95ab96dbb6172055ab7935')
+md5sums_x86_64=('271a05b8b40b2fc7dc81c844162b3971')
diff --git a/abs/extra/plex-media-server/__changelog b/abs/extra/plex-media-server/__changelog
index f410839..e7bd5d2 100644
--- a/abs/extra/plex-media-server/__changelog
+++ b/abs/extra/plex-media-server/__changelog
@@ -1,6 +1,6 @@
+PKGBUILD - remove arch arm and i686 and comment out sources
 .install & conf.d - change /var/lib/plex to /data/storage/disk0/media/plex
 conf.d - change /tmp to data/storage/disk0/media/plex/tmp
 plex-media-server.install - add check for data/storage/disk0/media/plex/tmp and create if needed
 plex-media-server.install - add_service.sh in post_install; remove_service.sh in post_remove
-PKGBUILD - move creation of /data/storage/disk0/media/plex to .install
 PKGBUILD - add plexmediascanner.sh
diff --git a/abs/extra/plex-media-server/plex-media-server.install b/abs/extra/plex-media-server/plex-media-server.install
index e677521..4c40a8a 100644
--- a/abs/extra/plex-media-server/plex-media-server.install
+++ b/abs/extra/plex-media-server/plex-media-server.install
@@ -1,45 +1,12 @@
 post_install() {
-  if [[ ! -d /data/storage/disk0/media/plex ]]; then
-    install -dm 755 /data/storage/disk0/media/plex
-    chown 421:421 -R /data/storage/disk0/media/plex    
-  fi
-  if [[ ! -d /data/storage/disk0/media/plex/tmp ]]; then
-    install -dm 755 /data/storage/disk0/media/plex/tmp
-    chown 421:421 -R /data/storage/disk0/media/plex/tmp
-  fi
-  if [[ -n $(getent group 421) && $(getent group 421) != $(getent group plex) ]]; then
-    echo "GID 421 is already assigned to the $(getent group 421 | cut -d':' -f1) group, cannot create the plex group."
-  elif [[ -n $(getent passwd 421) && $(getent passwd 421) != $(getent passwd plex) ]]; then
-    echo "UID 421 is already assigned to the $(getent passwd 421 | cut -d':' -f1) user, cannot create the plex user."
-  else
-    if [[ -n $(getent passwd plex) && $(getent passwd plex) != 'plex:x:421:421:Plex User:/data/storage/disk0/media/plex:/usr/bin/nologin' ]]; then
-      echo "The plex user is outdated. It will be removed and recreated."
-      if [[ -z $(pidof "Plex Media Server") ]]; then
-        userdel plex
-        chown 421:421 -R /data/storage/disk0/media/plex
-      else
-        echo "Unable to update the plex user. Please stop plexmediaserver.service and reinstall the package."
-      fi
-    fi
-    if [[ -z $(getent group plex) ]]; then
-      groupadd -g 421 plex
-    fi
-    if [[ -z $(getent passwd plex) ]]; then
-      useradd -c 'Plex User' -u 421 -g plex -d /data/storage/disk0/media/plex -s /usr/bin/nologin plex
-    fi
-    passwd -l plex > /dev/null
-  fi
+  systemd-sysusers plex.conf
+  [[ -d /data/storage/disk0/media/plex ]] || install -dm 750 -o plex -g plex /data/storage/disk0/media/plex
+  [[ -d /data/storage/disk0/media/plex/tmp ]] || install -dm 750 -o plex -g plex /data/storage/disk0/media/plex/tmp
   add_service.sh plexmediaserver
 }
 
-post_upgrade() {
-  post_install
-  if [[ $(vercmp 0.9.11.1.678-1 $2) == '1' ]]; then
-    echo "Plex' home is now located in '/var/lib/plex'. You will have to move the 'Plex Media Server' directory located in '/opt/plexmediserver/Library/Application Support' into the new home. Please refer to 'https://support.plex.tv/hc/en-us/articles/201370363-Move-an-Install-to-Another-System' for detailed instructions."
-  fi
-}
-
 post_remove() {
   remove_service.sh plexmediaserver
 }
+
 # vim: ts=2 sw=2 et:
diff --git a/abs/extra/plex-media-server/plex.sysusers b/abs/extra/plex-media-server/plex.sysusers
new file mode 100644
index 0000000..e23680f
--- /dev/null
+++ b/abs/extra/plex-media-server/plex.sysusers
@@ -0,0 +1,2 @@
+u plex - "Plex Media Server" /opt/plexmediaserver
+
diff --git a/abs/extra/plex-media-server/plexmediaserver.service b/abs/extra/plex-media-server/plexmediaserver.service
index 9206301..55b3325 100644
--- a/abs/extra/plex-media-server/plexmediaserver.service
+++ b/abs/extra/plex-media-server/plexmediaserver.service
@@ -3,6 +3,7 @@ Description=Plex Media Server
 After=network.target
 
 [Service]
+WorkingDirectory=/opt/plexmediaserver
 EnvironmentFile=/etc/conf.d/plexmediaserver
 ExecStart=/opt/plexmediaserver/Plex\x20Media\x20Server
 Type=simple
-- 
cgit v0.12

