]> git.ipfire.org Git - thirdparty/tvheadend.git/commitdiff
Fix handling of legacy configuration directories in debian/postinst
authorMichael Marley <michael@michaelmarley.com>
Fri, 2 Feb 2024 16:38:07 +0000 (11:38 -0500)
committerFlole998 <Flole998@users.noreply.github.com>
Fri, 2 Feb 2024 21:54:00 +0000 (22:54 +0100)
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.

debian/tvheadend.postinst

index 737b20ba30bd84c293f108f760889fd66578cd2c..cdda7b9b01b1df6cc0efc46a719b402af76b6e68 100644 (file)
@@ -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}"