From: Michael Marley Date: Fri, 2 Feb 2024 16:38:07 +0000 (-0500) Subject: Fix handling of legacy configuration directories in debian/postinst X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=360ece9f140f2498138c3a169363dc9c6cb4add6;p=thirdparty%2Ftvheadend.git Fix handling of legacy configuration directories in debian/postinst Detect if the HTS user's home directory starts with "/home/", which indicates the legacy configuration directory is in use, and use the correct paths for the "recordings" directory and "superuser" file. This prevents a useless files/directories from being created and ensures that "dpkg-reconfigure tvheadend" still updates the superuser credentials correctly. --- diff --git a/debian/tvheadend.postinst b/debian/tvheadend.postinst index 737b20ba3..cdda7b9b0 100644 --- a/debian/tvheadend.postinst +++ b/debian/tvheadend.postinst @@ -13,11 +13,22 @@ configure) adduser --quiet --system --group --home /var/lib/tvheadend $HTS_USER fi - HTS_HOME=`getent passwd $HTS_USER | cut -d':' -f6` + HTS_HOMEDIR=`getent passwd $HTS_USER | cut -d':' -f6` + + # Handle previous configuration directory: If the HTS_USER home directory + # starts with /home/, append "/.hts/tvheadend" so the superuser + # configuration will go in the right place. + if [ -z "${HTS_HOMEDIR##/home/*}" ]; then + HTS_CONFDIR="$HTS_HOMEDIR/.hts/tvheadend" + echo >&2 "Legacy configuration directory $HTS_CONFDIR is in use." + install -d -g ${HTS_USER} -o ${HTS_USER} "${HTS_CONFDIR}" + else + HTS_CONFDIR="$HTS_HOMEDIR" + fi - install -d -g ${HTS_USER} -o ${HTS_USER} "${HTS_HOME}/recordings" + install -d -g ${HTS_USER} -o ${HTS_USER} "${HTS_HOMEDIR}/recordings" - HTS_SUPERUSERCONF="${HTS_HOME}/superuser" + HTS_SUPERUSERCONF="${HTS_CONFDIR}/superuser" rm -f "${HTS_SUPERUSERCONF}" touch "${HTS_SUPERUSERCONF}" chmod 600 "${HTS_SUPERUSERCONF}"