PREIN
/bin/sh
# create a user "tvheadend" with a home directory /var/lib/tvheadend
# with no login shell and make him a member of the video group
/usr/share/rpm-helper/add-user tvheadend $1 tvheadend /var/lib/tvheadend /sbin/nologin
gpasswd -a tvheadend video >/dev/null
PREUN
/bin/sh
/usr/share/rpm-helper/del-service tvheadend $1 tvheadend
POSTIN
/bin/sh
chown tvheadend:root /var/lib/tvheadend
cd /var/lib/tvheadend
chown -R tvheadend:video .hts*
# check if the access control file still has the initial dummy password, and
# replace the dummy password by a random, 12-character pwgen-generated password
if grep -q '"password": "dummypassword"' /var/lib/tvheadend/.hts/tvheadend/accesscontrol/1; then
sed -i "s,\"password\": \"dummypassword\",\"password\": \"$(pwgen -s 12 1)\"," /var/lib/tvheadend/.hts/tvheadend/accesscontrol/1
fi
/usr/share/rpm-helper/add-service tvheadend $1 tvheadend