]> git.ipfire.org Git - thirdparty/tvheadend.git/commitdiff
Clean up Debian postinst and postrm scripts
authorMichael Marley <michael@michaelmarley.com>
Fri, 2 Feb 2024 16:42:16 +0000 (11:42 -0500)
committerFlole998 <Flole998@users.noreply.github.com>
Fri, 2 Feb 2024 21:54:00 +0000 (22:54 +0100)
- Fix indentation
- Remove unnecessary {} around variables
- Double-quote all variables when assigned or used as arguments
- Simplify quotes and escaping in creation of the superuser file
- Remove needless variable assignments
- Use $() for command substitution instead of ``

debian/tvheadend.postinst
debian/tvheadend.postrm

index cdda7b9b01b1df6cc0efc46a719b402af76b6e68..eff115c9d41c4d4dc5df9b97965ef0012d574d64 100644 (file)
@@ -1,51 +1,50 @@
 #!/bin/sh -e
 
-HTS_USER=hts
+HTS_USER="hts"
 
 . /usr/share/debconf/confmodule
 db_version 2.0
 
 case "$1" in
 configure)
-
-   if ! getent passwd $HTS_USER >/dev/null; then
+    if ! getent passwd "$HTS_USER" >/dev/null; then
         echo >&2 "Creating user: $HTS_USER..."
-        adduser --quiet --system --group --home /var/lib/tvheadend $HTS_USER
-   fi
+        adduser --quiet --system --group --home /var/lib/tvheadend "$HTS_USER"
+    fi
 
-   HTS_HOMEDIR=`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
+    # 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
+        install -d -g "$HTS_USER" -o "$HTS_USER" "$HTS_CONFDIR"
+    else
         HTS_CONFDIR="$HTS_HOMEDIR"
-   fi
+    fi
 
-   install -d -g ${HTS_USER} -o ${HTS_USER} "${HTS_HOMEDIR}/recordings"
+    install -d -g "$HTS_USER" -o "$HTS_USER" "$HTS_HOMEDIR/recordings"
 
-   HTS_SUPERUSERCONF="${HTS_CONFDIR}/superuser"
-   rm -f "${HTS_SUPERUSERCONF}"
-   touch "${HTS_SUPERUSERCONF}"
-   chmod 600 "${HTS_SUPERUSERCONF}"
-   chown ${HTS_USER}:${HTS_USER} "${HTS_SUPERUSERCONF}"
+    HTS_SUPERUSERCONF="${HTS_CONFDIR}/superuser"
+    rm -f "$HTS_SUPERUSERCONF"
+    touch "$HTS_SUPERUSERCONF"
+    chmod 600 "$HTS_SUPERUSERCONF"
+    chown "$HTS_USER":"$HTS_USER" "$HTS_SUPERUSERCONF"
 
-   echo >>"${HTS_SUPERUSERCONF}" "{"
+    echo >>"$HTS_SUPERUSERCONF" "{"
 
-   if db_get tvheadend/admin_username; then
-       echo >>"${HTS_SUPERUSERCONF}" '"username": "'$RET'",'
-   fi
+    if db_get tvheadend/admin_username; then
+        echo >>"$HTS_SUPERUSERCONF" "\"username\": \"$RET\","
+    fi
 
-   if db_get tvheadend/admin_password; then
-       echo >>"${HTS_SUPERUSERCONF}" '"password": "'$RET'"'
-   fi
+    if db_get tvheadend/admin_password; then
+        echo >>"$HTS_SUPERUSERCONF" "\"password\": \"$RET\""
+    fi
     
-   echo >>"${HTS_SUPERUSERCONF}" "}"
-   ;;
+    echo >>"$HTS_SUPERUSERCONF" "}"
+    ;;
 esac
 
 db_stop
index 39af2a42393016a0676bfe0472f7f79e5c433be1..271bf1a119400d097586f4588ae92e0fd63d8b2d 100644 (file)
@@ -1,15 +1,14 @@
 #!/bin/sh -e
 
-HTS_USER=hts
+HTS_USER="hts"
 
 . /usr/share/debconf/confmodule
 db_version 2.0
 
 case "$1" in
 purge)
-    if getent passwd $HTS_USER >/dev/null; then
-        HTS_HOME=`getent passwd $HTS_USER | cut -d':' -f6`
-        rm -rf "${HTS_HOME}"
+    if getent passwd "$HTS_USER" >/dev/null; then
+        rm -rf "$(getent passwd "$HTS_USER" | cut -d':' -f6)"
     fi
     db_purge
    ;;