plexmediaserver.SlackBuild 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146
  1. #!/bin/bash
  2. # Slackware build script for "plexmediaserver".
  3. # Copyright 2014-2015 Lionel Young <lionelyoung@gmail.com>
  4. # Copyright 2015-2017 Marcel Saegebarth <marc@mos6581.de>
  5. # Copyright 2017-2020 Kevin Matthew <kevin@kevinmatthew.com>
  6. # Copyright 2020-2022 Stu Miller <slackbuilds@go4it2day.com>
  7. # All rights reserved.
  8. #
  9. # Redistribution and use in source and binary forms, with or without
  10. # modification, are permitted provided that the following conditions are
  11. # met:
  12. #
  13. # * Redistributions of source code must retain the above copyright
  14. # notice, this list of conditions and the following disclaimer.
  15. #
  16. # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  17. # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  18. # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
  19. # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
  20. # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  21. # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  22. # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
  23. # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  24. # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  25. # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  26. # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  27. cd $(dirname $0) ; CWD=$(pwd)
  28. PRGNAM=plexmediaserver
  29. VERSION=${VERSION:-1.25.9.5721_965587f64}
  30. PKG_VERSION=$(echo $VERSION | tr _ -)
  31. BUILD=${BUILD:-1}
  32. TAG=${TAG:-_SBo}
  33. PKGTYPE=${PKGTYPE:-tgz}
  34. if [ -z "$ARCH" ]; then
  35. case "$( uname -m )" in
  36. i?86) ARCH=i586 ;;
  37. arm*) ARCH=arm ;;
  38. *) ARCH=$( uname -m ) ;;
  39. esac
  40. fi
  41. # If the variable PRINT_PACKAGE_NAME is set, then this script will report what
  42. # the name of the created package would be, and then exit. This information
  43. # could be useful to other scripts.
  44. if [ ! -z "${PRINT_PACKAGE_NAME}" ]; then
  45. echo "$PRGNAM-$VERSION-$ARCH-$BUILD$TAG.$PKGTYPE"
  46. exit 0
  47. fi
  48. TMP=${TMP:-/tmp/SBo}
  49. PKG=$TMP/package-$PRGNAM
  50. OUTPUT=${OUTPUT:-/tmp}
  51. if [ "$ARCH" = "i586" ]; then
  52. DEBARCH="i386"
  53. LIBDIRSUFFIX=""
  54. ARCH="i386"
  55. elif [ "$ARCH" = "i686" ]; then
  56. DEBARCH="i386"
  57. LIBDIRSUFFIX=""
  58. ARCH="i386"
  59. elif [ "$ARCH" = "x86_64" ]; then
  60. DEBARCH="amd64"
  61. LIBDIRSUFFIX="64"
  62. ARCH="x86_64"
  63. else
  64. echo "Package for $(uname -m) architecture is not available."
  65. exit 1
  66. fi
  67. PLEX_USER=${PLEX_USER:-279}
  68. PLEX_GROUP=${PLEX_GROUP:-279}
  69. set -e
  70. # Bail if user or group isn't valid on your system
  71. if ! getent passwd plex 1>/dev/null 2>/dev/null; then
  72. cat << EOF
  73. You must have a plex user to run this script
  74. # groupadd -g $PLEX_USER plex
  75. # useradd -u $PLEX_USER -d /var/lib/$PRGNAM -s /bin/false -g plex plex
  76. EOF
  77. exit 1
  78. elif ! getent group plex 1>/dev/null 2>/dev/null; then
  79. cat << EOF
  80. You must have a plex group to run this script
  81. # groupadd -g $PLEX_GROUP plex
  82. EOF
  83. exit 1
  84. fi
  85. rm -rf $PKG
  86. mkdir -p $TMP $PKG $OUTPUT
  87. cd $TMP
  88. rm -rf $PRGNAM-$VERSION
  89. mkdir $PRGNAM-$VERSION
  90. ar xv $CWD/${PRGNAM}_${PKG_VERSION}_${DEBARCH}.deb data.tar.xz
  91. tar xvf data.tar.xz -C $PRGNAM-$VERSION
  92. rm -f data.tar.xz
  93. cd $PRGNAM-$VERSION
  94. chown -R root:root .
  95. find -L . \
  96. \( -perm 777 -o -perm 775 -o -perm 750 -o -perm 711 -o -perm 555 \
  97. -o -perm 511 \) -exec chmod 755 {} \; -o \
  98. \( -perm 666 -o -perm 664 -o -perm 640 -o -perm 600 -o -perm 444 \
  99. -o -perm 440 -o -perm 400 \) -exec chmod 644 {} \;
  100. mkdir -p $PKG/usr/lib/
  101. mv usr/lib/plexmediaserver $PKG/usr/lib
  102. mkdir -p $PKG/usr/share/applications/
  103. mv usr/share/applications/plexmediaserver.desktop $PKG/usr/share/applications
  104. sed -i -e "s/x-www-browser/xdg-open/" $PKG/usr/share/applications/plexmediaserver.desktop
  105. mkdir -p $PKG/etc/rc.d
  106. cat $PKG/usr/lib/$PRGNAM/lib/$PRGNAM.init > $PKG/etc/rc.d/rc.$PRGNAM.new
  107. chmod 0644 $PKG/etc/rc.d/rc.$PRGNAM.new
  108. mkdir -p $PKG/etc/default
  109. cat $PKG/usr/lib/plexmediaserver/lib/plexmediaserver.default > $PKG/etc/default/$PRGNAM.new
  110. chmod 0644 $PKG/etc/default/$PRGNAM.new
  111. mkdir -p $PKG/usr/doc/$PRGNAM-$VERSION
  112. cat $CWD/$PRGNAM.SlackBuild > $PKG/usr/doc/$PRGNAM-$VERSION/$PRGNAM.SlackBuild
  113. mkdir -p $PKG/var/lib/$PRGNAM
  114. chown -R $PLEX_USER:$PLEX_GROUP $PKG/var/lib/$PRGNAM
  115. mkdir -p $PKG/install
  116. cat $CWD/slack-desc > $PKG/install/slack-desc
  117. cat $CWD/doinst.sh > $PKG/install/doinst.sh
  118. cd $PKG
  119. /sbin/makepkg -l y -c n $OUTPUT/$PRGNAM-$VERSION-$ARCH-$BUILD$TAG.$PKGTYPE