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