Skip to content

Commit

Permalink
tvheadend: Remove legacy root dir recording fix
Browse files Browse the repository at this point in the history
Based on feedbacks from previous maintainer remove unecessary
code to manage faulty root directory recordings.
Ref: SynoCommunity#4545 (comment)
  • Loading branch information
th0ma7 authored and hgy59 committed Jun 14, 2021
1 parent 6dd7c54 commit dbd91b7
Showing 1 changed file with 1 addition and 50 deletions.
51 changes: 1 addition & 50 deletions spk/tvheadend/src/service-setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,7 @@ HTSP=9982

# Replace generic service startup, run service in background
GRPN=$(id -gn ${EFF_USER})
DVR_LOG_DIR="${SYNOPKG_PKGVAR}/dvr/log"
UPGRADE_CFG_DIR="${SYNOPKG_PKGVAR}/dvr/config"
SAVE_DIR="/tmp/tvheadend-recording-backup"
SERVICE_COMMAND="${SYNOPKG_PKGDEST}/bin/tvheadend -f -u ${EFF_USER} -g ${GRPN} --http_port ${HTTP} --htsp_port ${HTSP} -c ${SYNOPKG_PKGVAR} -p ${PID_FILE}"
SVC_BACKGROUND=yes

Expand Down Expand Up @@ -37,57 +35,10 @@ service_postinst ()

service_preupgrade ()
{
# Backup potential recordings from package root directory
echo "Save potential recordings from package root directory..."
for logfile in ${DVR_LOG_DIR}/*
do
REC_FILE=$(grep -e 'filename' ${logfile} | awk -F'"' '{print $4}')
# Check whether recording actually exists, otherwise ignore the entry
if [ -e "${REC_FILE}" ]; then
REC_DIR=$(dirname "${REC_FILE}")
REAL_DIR=$(realpath "${REC_DIR}")
TRUNC_DIR=$(echo "${REAL_DIR}" | cut -c9-28)
CHECK_VAR=$(echo "${REAL_DIR}" | cut -c29-32)
if [ ! "${REC_FILE}" = "" ] && [ "${TRUNC_DIR}" = "/@appstore/tvheadend" ] && [ ! "${CHECK_VAR}" = "/var" ]; then
REC_NAME=$(basename "${REC_FILE}")
REST_DIR=$(echo "${REAL_DIR}" | cut -c30-)
DEST_FILE="${SAVE_DIR}/${REST_DIR}/${REC_NAME}"
echo "Saving: ${REC_FILE}"
$MKDIR "${SAVE_DIR}/${REST_DIR}"
$CP "${REC_FILE}" "${DEST_FILE}"
# Replace any remaining target links in log files first
sed -i -e "s,${SYNOPKG_PKGDEST},/usr/local/tvheadend/,g" "${logfile}"
# Adapt recording paths in dvr log files for restored files (postupgrade)
sed -i -e "s,/tvheadend/,/tvheadend/var/,g" "${logfile}"
fi
fi
done
# Move recording directories from package root into var
echo "Move any recording directories from package root directory into var..."
for file in ${UPGRADE_CFG_DIR}/*
do
DVR_DIR=$(grep -e 'storage\":' ${file} | awk -F'"' '{print $4}')
REAL_DIR=$(realpath "${DVR_DIR}")
TRUNC_DIR=$(echo "${REAL_DIR}" | cut -c9-28)
CHECK_VAR=$(echo "${REAL_DIR}" | cut -c29-32)
# Replace any remaining target links in log files first
sed -i -e "s,${SYNOPKG_PKGDEST},/usr/local/tvheadend,g" "${file}"
if [ "${TRUNC_DIR}" = "/@appstore/tvheadend" ] && [ ! "${CHECK_VAR}" = "/var" ]; then
# Move recording paths in recording profiles into var
sed -i -e "s,/tvheadend,/tvheadend/var,g" "${file}"
fi
done
}

service_postupgrade ()
{
# For backwards compatibility, restore recordings from old package root into var directory
if [ -d "${SAVE_DIR}" ]; then
echo "Restoring recordings into ${SYNOPKG_PKGVAR}"
$CP "${SAVE_DIR}"/. "${SYNOPKG_PKGVAR}"
$RM "${SAVE_DIR}"
fi

# Need to enforce correct permissions for recording directories on upgrades
echo "Adding ${GROUP} group permissions on recording directories:"
for file in ${UPGRADE_CFG_DIR}/*
Expand All @@ -104,8 +55,8 @@ service_postupgrade ()
done

# For backwards compatibility, restore ownership of package system directories
echo "Restore '${EFF_USER}' unix permissions on package system directories"
if [ $SYNOPKG_DSM_VERSION_MAJOR == 6 ]; then
echo "Restore '${EFF_USER}' unix permissions on package system directories"
chown ${EFF_USER}:${USER} "${SYNOPKG_PKGDEST}"
set_unix_permissions "${SYNOPKG_PKGVAR}"
fi
Expand Down

0 comments on commit dbd91b7

Please sign in to comment.