From b1f4df7aee3de293bacf67e368b5e8c16282b866 Mon Sep 17 00:00:00 2001 From: pdulvp Date: Mon, 18 Nov 2024 23:36:41 +0100 Subject: [PATCH] Update scripts --- jellyfin-ffmpeg.sh | 38 +++----------- jellyfin-server.sh | 8 ++- package.json | 14 ++--- packaging/qpkg.cfg | 2 +- packaging/shared/jellyfin-config.sh | 73 ++++++++++++++++++++++++++ packaging/shared/jellyfin-helpers.sh | 23 -------- packaging/shared/jellyfin.sh | 16 +----- packaging/shared/user-config.sh.sample | 18 ++++--- 8 files changed, 105 insertions(+), 87 deletions(-) create mode 100644 packaging/shared/jellyfin-config.sh delete mode 100644 packaging/shared/jellyfin-helpers.sh diff --git a/jellyfin-ffmpeg.sh b/jellyfin-ffmpeg.sh index 64e2873..7c7f5e8 100644 --- a/jellyfin-ffmpeg.sh +++ b/jellyfin-ffmpeg.sh @@ -47,21 +47,10 @@ CONF=/etc/config/qpkg.conf; QPKG_NAME="jellyfin"; QPKG_ROOT=\`/sbin/getcfg \$QPKG_NAME Install_Path -f \${CONF}\` -## Look at the config for which VaapiDriver to use from the Jellyfin.Plugin.QnapConfiguration if installed -LIBVA_FROM_CONFIG=\`[ -f \$QPKG_ROOT/database/plugins/configurations/Jellyfin.Plugin.QnapConfiguration.xml ] && cat \$QPKG_ROOT/database/plugins/configurations/Jellyfin.Plugin.QnapConfiguration.xml | grep -E "([^<]+)" | cut -d">" -f2 | cut -d"<" -f1\` -if [ ! -z \${LIBVA_FROM_CONFIG} ]; then - if [ "\$LIBVA_FROM_CONFIG" != "defaultValue" ]; then - export LIBVA_DRIVER_NAME_JELLYFIN="\$LIBVA_FROM_CONFIG" - export LIBVA_DRIVER_NAME="\$LIBVA_FROM_CONFIG" - fi -fi - -ADDITIONAL_PATHS="" -if [ -d /opt/NVIDIA_GPU_DRV/usr/nvidia ]; then - ADDITIONAL_PATHS=":/opt/NVIDIA_GPU_DRV/usr/nvidia" -fi +source \$QPKG_ROOT/jellyfin-config.sh +jellyfin_ffmpeg_start "\$@" -\$QPKG_ROOT/jellyfin/bin/$LD_LIB --library-path \$QPKG_ROOT/jellyfin-ffmpeg/lib:\$QPKG_ROOT/jellyfin/bin\$ADDITIONAL_PATHS \$QPKG_ROOT/jellyfin-ffmpeg/ffmpeg2 "\$@" +\$QPKG_ROOT/jellyfin/bin/$LD_LIB --library-path \$QPKG_ROOT/jellyfin-ffmpeg/lib:\$QPKG_ROOT/jellyfin/bin\$QPKGS_PATHS \$QPKG_ROOT/jellyfin-ffmpeg/ffmpeg2 "\$@" EOL cat >output/shared/jellyfin-ffmpeg/ffprobe <([^<]+)" | cut -d">" -f2 | cut -d"<" -f1\` -if [ ! -z \${LIBVA_FROM_CONFIG} ]; then - if [ "\$LIBVA_FROM_CONFIG" != "defaultValue" ]; then - export LIBVA_DRIVER_NAME_JELLYFIN="\$LIBVA_FROM_CONFIG" - export LIBVA_DRIVER_NAME="\$LIBVA_FROM_CONFIG" - fi -fi +source \$QPKG_ROOT/jellyfin-config.sh +jellyfin_ffprobe_start "\$@" -ADDITIONAL_PATHS="" -if [ -d /opt/NVIDIA_GPU_DRV/usr/nvidia ]; then - ADDITIONAL_PATHS=":/opt/NVIDIA_GPU_DRV/usr/nvidia" -fi \$QPKG_ROOT/jellyfin/bin/$LD_LIB --library-path \$QPKG_ROOT/jellyfin-ffmpeg/lib:\$QPKG_ROOT/jellyfin/bin\$ADDITIONAL_PATHS \$QPKG_ROOT/jellyfin-ffmpeg/ffprobe2 "\$@" EOL @@ -94,10 +73,9 @@ CONF=/etc/config/qpkg.conf; QPKG_NAME="jellyfin"; QPKG_ROOT=\`/sbin/getcfg \$QPKG_NAME Install_Path -f \${CONF}\` -ADDITIONAL_PATHS="" -if [ -d /opt/NVIDIA_GPU_DRV/usr/nvidia ]; then - ADDITIONAL_PATHS=":/opt/NVIDIA_GPU_DRV/usr/nvidia" -fi +source \$QPKG_ROOT/jellyfin-config.sh +jellyfin_vainfo_start "\$@" + if [ -f \$QPKG_ROOT/jellyfin-ffmpeg/vainfo2 ]; then \$QPKG_ROOT/jellyfin/bin/$LD_LIB --library-path \$QPKG_ROOT/jellyfin-ffmpeg/lib:\$QPKG_ROOT/jellyfin/bin\$ADDITIONAL_PATHS \$QPKG_ROOT/jellyfin-ffmpeg/vainfo2 "\$@" fi diff --git a/jellyfin-server.sh b/jellyfin-server.sh index 2e532f3..aa010db 100644 --- a/jellyfin-server.sh +++ b/jellyfin-server.sh @@ -39,12 +39,10 @@ CONF=/etc/config/qpkg.conf; QPKG_NAME="jellyfin"; QPKG_ROOT=\`/sbin/getcfg \$QPKG_NAME Install_Path -f \${CONF}\` -ADDITIONAL_PATHS="" -if [ -d /opt/NVIDIA_GPU_DRV/usr/nvidia ]; then - ADDITIONAL_PATHS=":/opt/NVIDIA_GPU_DRV/usr/nvidia" -fi +source \$QPKG_ROOT/jellyfin-config.sh +jellyfin_server_start "\$@" -\$QPKG_ROOT/jellyfin/bin/$LD_LIB --library-path \$QPKG_ROOT/jellyfin/bin:\$QPKG_ROOT/jellyfin-ffmpeg/lib\$ADDITIONAL_PATHS \$QPKG_ROOT/jellyfin/bin/jellyfin2 "\$@" +\$QPKG_ROOT/jellyfin/bin/$LD_LIB --library-path \$QPKG_ROOT/jellyfin/bin:\$QPKG_ROOT/jellyfin-ffmpeg/lib\$QPKGS_PATHS \$QPKG_ROOT/jellyfin/bin/jellyfin2 "\$@" EOL chmod +x output/shared/jellyfin/bin/jellyfin diff --git a/package.json b/package.json index cd9f5a8..a475297 100644 --- a/package.json +++ b/package.json @@ -2,14 +2,14 @@ "name": "jellyfin-qnap", "preversion": "1080-beta3.1080-beta3.5014", "presha": "10.8.0-beta3_fef37ac1c887de65574ce94688f1f479", - "version": "10101.10101.7026.5143", - "sha": "08438cb65ddaee1d4355f5581b8", - "server": "10.10.1", - "ffmpeg": "7.0.2-6", + "version": "10102.10102.7027.5143", + "sha": "ba7131036e4c7babd774a8e9e1a426c9", + "server": "10.10.2", + "ffmpeg": "7.0.2-7", "ffmpeg5": "5.1.4-3", - "web": "10.10.1", + "web": "10.10.2", "description": "", - "suffix": "03", + "suffix": "01", "main": "index.js", "scripts": { "build": "debian.exe run 'cd /mnt/c/Works/jellyfin-qnap; if [ -f ./init.sh ]; then source ./init.sh; fi; ./make.sh'", @@ -25,4 +25,4 @@ "url": "https://github.com/pdulvp/jellyfin-qnap/issues" }, "homepage": "https://github.com/pdulvp/jellyfin-qnap#readme" -} \ No newline at end of file +} diff --git a/packaging/qpkg.cfg b/packaging/qpkg.cfg index 722c9ee..f0d9b69 100644 --- a/packaging/qpkg.cfg +++ b/packaging/qpkg.cfg @@ -32,7 +32,7 @@ QPKG_SERVICE_PROGRAM="jellyfin.sh" # Location of file with running service's PID #QPKG_SERVICE_PIDFILE="" # Relative path to web interface -QPKG_WEBUI="/" +QPKG_WEBUI="/web/" # Port number for the web interface. QPKG_WEB_PORT="8096" # Port number for the SSL web interface. diff --git a/packaging/shared/jellyfin-config.sh b/packaging/shared/jellyfin-config.sh new file mode 100644 index 0000000..bc8a29c --- /dev/null +++ b/packaging/shared/jellyfin-config.sh @@ -0,0 +1,73 @@ +#!/bin/sh +CONF=/etc/config/qpkg.conf +QPKG_NAME="jellyfin" +QPKG_ROOT=`/sbin/getcfg $QPKG_NAME Install_Path -f ${CONF}` +CMD_SETCFG="/sbin/setcfg" + +set_qpkg_field(){ + qpkg_field=$1 + value=$2 + current_value=`/sbin/getcfg ${QPKG_NAME} ${qpkg_field} -f ${CONF}` + [ ! -z "${value}" ] && [ "${current_value}" != "${value}" ] && `${CMD_SETCFG} "${QPKG_NAME}" "${qpkg_field}" "${value}" -f "${CONF}"` +} + +get_from_config(){ + config_file=$1 + config_field=$2 + value=$(cat "$QPKG_ROOT/${config_file}" | grep "${config_field}" | cut -f2 -d\> | cut -f1 -d\< ) + echo "${value}" +} + +set_from_config(){ + config_file=$1 + config_field=$2 + qpkg_field=$3 + default_value=$4 + value=$(get_from_config "${config_file}" "${config_field}") + [ -z "${value}" ] && value="${default_value}" + set_qpkg_field "${qpkg_field}" "${value}" +} + +default_config(){ + set_from_config "conf/network.xml" "InternalHttpPort" "Web_Port" "8096" + set_from_config "conf/network.xml" "InternalHttpsPort" "Web_SSL_Port" "8920" + + export TMPDIR="$QPKG_ROOT/cache/tmp" + export QPKGS_PATHS="" + if [ -d /opt/NVIDIA_GPU_DRV/usr/nvidia ]; then + QPKGS_PATHS=":/opt/NVIDIA_GPU_DRV/usr/nvidia" + fi + export QPKGS_PATHS=":/opt/NVIDIA_GPU_DRV/usr/nvidia" +} + +load_config(){ + default_config + if [ -f "$QPKG_ROOT/user-config.sh" ]; then + source $QPKG_ROOT/user-config.sh; + user_config + fi +} + +jellyfin_ffmpeg_start() { + ## Look at the config for which VaapiDriver to use from the Jellyfin.Plugin.QnapConfiguration if installed + LIBVA_FROM_CONFIG=`[ -f $QPKG_ROOT/database/plugins/configurations/Jellyfin.Plugin.QnapConfiguration.xml ] && cat $QPKG_ROOT/database/plugins/configurations/Jellyfin.Plugin.QnapConfiguration.xml | grep -E "([^<]+)" | cut -d">" -f2 | cut -d"<" -f1` + if [ ! -z "${LIBVA_FROM_CONFIG}" ]; then + if [ "$LIBVA_FROM_CONFIG" != "defaultValue" ]; then + export LIBVA_DRIVER_NAME_JELLYFIN="$LIBVA_FROM_CONFIG" + export LIBVA_DRIVER_NAME="$LIBVA_FROM_CONFIG" + fi + fi + return 0 +} + +jellyfin_ffprobe_start() { + return 0 +} + +jellyfin_vainfo_start() { + return 0 +} + +jellyfin_server_start() { + return 0 +} diff --git a/packaging/shared/jellyfin-helpers.sh b/packaging/shared/jellyfin-helpers.sh deleted file mode 100644 index 132857e..0000000 --- a/packaging/shared/jellyfin-helpers.sh +++ /dev/null @@ -1,23 +0,0 @@ -#!/bin/sh -CONF=/etc/config/qpkg.conf -QPKG_NAME="jellyfin" -QPKG_ROOT=`/sbin/getcfg $QPKG_NAME Install_Path -f ${CONF}` - -set_value(){ - qpkg_field=$1 - value=$2 - - current_value=`/sbin/getcfg $QPKG_NAME $qpkg_field -f ${CONF}` - [ ! -z "$value" ] && [ "$current_value" -ne "$value" ] && `/sbin/setcfg $QPKG_NAME $qpkg_field "$value" -f ${CONF}` -} - -set_from_config(){ - config_file=$1 - config_field=$2 - qpkg_field=$3 - default_value=$4 - - value=$(cat $QPKG_ROOT/$config_file | grep $config_field | cut -f2 -d\> | cut -f1 -d\< ) - [ -z "$value" ] && value=$default_value - set_value $qpkg_field $value -} diff --git a/packaging/shared/jellyfin.sh b/packaging/shared/jellyfin.sh index 25af8a2..9eef5e4 100644 --- a/packaging/shared/jellyfin.sh +++ b/packaging/shared/jellyfin.sh @@ -2,19 +2,9 @@ CONF=/etc/config/qpkg.conf QPKG_NAME="jellyfin" QPKG_ROOT=`/sbin/getcfg $QPKG_NAME Install_Path -f ${CONF}` -export QNAP_QPKG=$QPKG_NAME export PATH=$QPKG_ROOT/jellyfin/bin:$QPKG_ROOT/jellyfin-ffmpeg:$PATH -#export LIBVA_DRIVER_NAME_JELLYFIN=i965 #iHD - -source ./jellyfin-helpers.sh - -default_config(){ - set_from_config "conf/network.xml" "InternalHttpPort" "Web_Port" "8096" - set_from_config "conf/network.xml" "InternalHttpsPort" "Web_SSL_Port" "8920" - - export TMPDIR="$QPKG_ROOT/cache/tmp" -} +source $QPKG_ROOT/jellyfin-config.sh jellyfin_start(){ /bin/ln -sf $QPKG_ROOT /opt/$QPKG_NAME @@ -22,9 +12,7 @@ jellyfin_start(){ ENABLED=$(/sbin/getcfg $QPKG_NAME Enable -u -d FALSE -f $CONF) - default_config - if [ -f ./user-config.sh ]; then source ./user-config.sh; fi - + load_config mkdir -p $QPKG_ROOT/logs $QPKG_ROOT/jellyfin-ffmpeg/vainfo > $QPKG_ROOT/logs/vainfo-$(date -d "today" +"%Y%m%d%H%M").log $QPKG_ROOT/jellyfin/bin/jellyfin --datadir=$QPKG_ROOT/database --cachedir=$QPKG_ROOT/cache --webdir=$QPKG_ROOT/jellyfin-web --configdir=$QPKG_ROOT/conf --logdir=$QPKG_ROOT/logs --ffmpeg=$QPKG_ROOT/jellyfin-ffmpeg/ffmpeg --package-name=pdulvp & diff --git a/packaging/shared/user-config.sh.sample b/packaging/shared/user-config.sh.sample index 4ff4ae1..a28319f 100644 --- a/packaging/shared/user-config.sh.sample +++ b/packaging/shared/user-config.sh.sample @@ -3,13 +3,17 @@ CONF=/etc/config/qpkg.conf QPKG_NAME="jellyfin" QPKG_ROOT=`/sbin/getcfg $QPKG_NAME Install_Path -f ${CONF}` -source ./jellyfin-helpers.sh +source $QPKG_ROOT/jellyfin-config.sh -#cat /etc/config/qpkg.conf for more options -set_value "Web_UI" "/" +user_config(){ + echo "Load user-configuration" -#export http_proxy="http://xxxx:xx" -#export https_proxy="http://xxxx:xx" -#export no_proxy= "192.168.168.0/24,localhost,127.0.0.1" + #Access to jellyfin with the QTS port + #set_qpkg_field "Use_Proxy" "1" + #set_qpkg_field "Proxy_Path" "/jellyfin/" -#export TMPDIR="\$QPKG_ROOT/cache/tmp" + #export http_proxy="http://xxxx:xx" + #export https_proxy="http://xxxx:xx" + #export no_proxy= "192.168.168.0/24,localhost,127.0.0.1" + return 0 +}