slackbuilds/n/jellyfin-bin/SlackBuild

146 lines
4 KiB
Text
Raw Permalink Normal View History

2024-11-29 18:14:06 +01:00
#!/bin/bash
CWD=$(pwd)
PKGNAM=$(basename "$CWD")
VERSION=${VERSION:-$(curl -s https://api.github.com/repos/jellyfin/jellyfin/releases/latest | grep tag_name | grep -o "[0-9.]*")}
ARCH=${ARCH:-$(uname -m)}
TAG=${TAG:-gwh}
BUILD=${BUILD:-3}
2024-11-29 18:14:06 +01:00
TMP=${TMP:-/tmp/$TAG}
PKG=$TMP/pkg-$PKGNAM
OUTPUT=${OUTPUT:-/tmp}
REPOSITORY=${REPOSITORY:-/var/cache/SlackBuilds.gwh/$PKGNAM}
mkdir -p "$REPOSITORY"
# echo $ARCH | grep -q arm && SRC_ARCH=arm-7
# echo $ARCH | grep -q 86 && SRC_ARCH=386
echo "$ARCH" | grep -q 64 && SRC_ARCH=amd64
mkdir -p "$REPOSITORY"
[ ! -e "$REPOSITORY/jellyfin_${VERSION}-${SRC_ARCH}.tar.xz" ] && wget -c "https://repo.jellyfin.org/files/server/linux/latest-stable/amd64/jellyfin_${VERSION}-${SRC_ARCH}.tar.xz" -O "$REPOSITORY/jellyfin_${VERSION}-${SRC_ARCH}.tar.xz"
rm -fr "$PKG"
mkdir -p "$PKG/opt/jellyfin"
cd "$PKG/opt/jellyfin" || exit 1
mkdir -p data cache config log
2024-11-29 18:14:06 +01:00
tar xvf "$REPOSITORY/jellyfin_${VERSION}-${SRC_ARCH}.tar.xz"
mv jellyfin jellyfin-${VERSION}
cd jellyfin-${VERSION} || exit 1
chown -R root:root .
find -L . \
\( -perm 777 -o -perm 775 -o -perm 750 -o -perm 711 -o -perm 555 \
-o -perm 511 \) -exec chmod 755 {} \; -o \
\( -perm 666 -o -perm 664 -o -perm 640 -o -perm 600 -o -perm 444 \
-o -perm 440 -o -perm 400 \) -exec chmod 644 {} \;
2024-11-29 18:14:06 +01:00
mkdir -p "$PKG/etc/default/"
cat <<EOF > "$PKG/etc/default/jellyfin"
# Below is the default values. Change them as you need them
DATADIR=/opt/jellyfin/data
CACHEDIR=/opt/jellyfin/cache
CONFIGDIR=/opt/jellyfin/config
LOGDIR=/opt/jellyfin/log
EOF
mkdir -p "$PKG/etc/rc.d/"
cat <<EOF > "$PKG/etc/rc.d/rc.$PKGNAM"
#!/bin/sh
### BEGIN INIT INFO
# Provides: Jellyfin Media Server
# Required-Start:
# Required-Stop:
# Default-Start: S
# Default-Stop:
# Short-Description: Jellyfin Media Server
# Description: Runs Jellyfin Media Server
### END INIT INFO
# Load the defaults
. /etc/default/jellyfin
start() {
if [ -x /opt/jellyfin/jellyfin-${VERSION}/jellyfin ]; then
2024-11-29 18:14:06 +01:00
echo "Starting Jellyfin Media Server"
/usr/bin/daemon --name=jellyfin --pidfile=/var/run/jellyfin.pid -- \
/opt/jellyfin/jellyfin-${VERSION}/jellyfin \
2024-11-29 18:14:06 +01:00
-d \$DATADIR \
-C \$CACHEDIR \
-c \$CONFIGDIR \
-l \$LOGDIR
2024-11-29 18:14:06 +01:00
fi
}
stop() {
echo "Stopping Jellyfin Media Server"
if /usr/bin/daemon --name=jellyfin --pidfile=/var/run/jellyfin.pid --running ; then
/usr/bin/daemon --name=jellyfin --pidfile=/var/run/jellyfin.pid --stop
fi
}
restart() {
echo "Restarting Jellyfin Media Server"
if /usr/bin/daemon --name=jellyfin --pidfile=/var/run/jellyfin.pid --running ; then
/usr/bin/daemon --name=jellyfin --pidfile=/var/run/jellyfin.pid --restart
fi
}
status() {
/usr/bin/daemon --name=jellyfin --running --pidfile=/var/run/jellyfin.pid --verbose
}
case "\$1" in
start)
start
;;
stop)
stop
;;
restart)
restart
;;
status)
status
;;
*)
echo "Usage: \$0 {start|stop|restart|status}"
exit 1
esac
EOF
chmod +x "$PKG/etc/rc.d/rc.$PKGNAM"
mkdir -p "$PKG/install"
cat <<EOF > "$PKG/install/slack-desc"
# HOW TO EDIT THIS FILE:
# The "handy ruler" below makes it easier to edit a package description.
# Line up the first '|' above the ':' following the base package name, and
# the '|' on the right side marks the last column you can put a character in.
# You must make exactly 11 lines for the formatting to be correct. It's also
# customary to leave one space after the ':' except on otherwise blank lines.
|-----handy-ruler------------------------------------------------------|
jellyfin-bin: jellyfin-bin (The Free Software Media System)
jellyfin-bin:
jellyfin-bin:
jellyfin-bin: Jellyfin is a volunteer-built media solution that puts you in control
jellyfin-bin: of your media. Stream to any device from your own server, with no
jellyfin-bin: strings attached. Your media, your server, your way.
jellyfin-bin:
jellyfin-bin: https://jellyfin.org/
jellyfin-bin:
jellyfin-bin:
jellyfin-bin:
EOF
cd "$PKG" || exit 1
/sbin/makepkg --linkadd y --chown n --prepend "$OUTPUT/$PKGNAM-$VERSION-$ARCH-$BUILD$TAG.txz"