jellyfin: update downloader to use mktemp

This commit is contained in:
heitbaum 2021-07-12 10:00:19 +00:00
parent a27a0b9622
commit 1e2ae5446e

View File

@ -6,7 +6,7 @@
. /etc/profile
oe_setup_addon service.jellyfin
ICON="$ADDON_DIR/resources/icon.png"
ICON="${ADDON_DIR}/resources/icon.png"
CONTROL_FILE="/tmp/curl.done"
DATA_FILE="/tmp/curl.data"
JELLYFIN_FILE="jellyfin_@JELLYFIN_VERSION@.tar.gz"
@ -18,21 +18,24 @@ if [ $(df . | awk 'END {print $4}') -lt 200000 ]; then
fi
# remove install status and folders
if [ -f $ADDON_DIR/extract.ok ]; then
rm $ADDON_DIR/extract.ok
if [ -f ${ADDON_DIR}/extract.ok ]; then
rm ${ADDON_DIR}/extract.ok
fi
if [ -d $ADDON_DIR/libs ]; then
rm -rf $ADDON_DIR/libs
fi
if [ -d $ADDON_DIR/tmp_download ]; then
rm -rf $ADDON_DIR/tmp_download
if [ -d ${ADDON_DIR}/libs ]; then
rm -rf ${ADDON_DIR}/libs
fi
# create tmp download dir
mkdir -p $ADDON_DIR/tmp_download
cd $ADDON_DIR/tmp_download
TEMP_DIR=`mktemp -d`
mkdir -p ${TEMP_DIR}/tmp_download
if [ -d ${TEMP_DIR}/tmp_download ]; then
cd ${TEMP_DIR}/tmp_download
else
kodi-send --action="Notification(Unable to download Jellyfin - no temp directory,30000,${ICON})" >/dev/null
exit 0
fi
echo "Downloading Jellyfin"
@ -55,11 +58,12 @@ rm -f ${CONTROL_FILE} ${DATA_FILE}
kodi-send --action="Notification(Extracting Jellyfin,Starting,1000,${ICON})" >/dev/null
# extract JELLYFIN_FILE to libs directory
mkdir $ADDON_DIR/libs
tar xf ${JELLYFIN_FILE} -C $ADDON_DIR/libs --strip-components=2
mkdir ${ADDON_DIR}/libs
tar xf ${JELLYFIN_FILE} -C ${ADDON_DIR}/libs --strip-components=2
# cleanup
cd $ADDON_DIR
rm -rf $ADDON_DIR/tmp_download
touch $ADDON_DIR/extract.ok
cd ${ADDON_DIR}
rm -rf ${TEMP_DIR}/tmp_download
rmdir ${TEMP_DIR}
touch ${ADDON_DIR}/extract.ok
kodi-send --action="Notification(Extracting Jellyfin,Finished,1000,${ICON})" >/dev/null