echo "Setting up plocate group..."
systemd-sysusers plocate.conf
systemd-tmpfiles --create plocate.conf

# The plocate-updatedb runs daily by default. Trigger it in postinst can provide
# an out-of-box experience for users. The updatedb operation is an idempotent
# operation. So, running it asynchronously won't do any harm even if the
# database generation is interrupted unexpectedly or experiencing any other forms
# of faliure. On the other hand, depending on the user's filesystem scenario,
# the updatedb process could take up to minutes, making it blocking the package
# installation process is quite undesirable.
echo "Triggering plocate database generation..."
systemctl daemon-reload
systemctl start --no-block \
    plocate-updatedb.timer \
    plocate-updatedb.service
