#!/bin/sh

config_file="$HOME/.config/plocate/updatedb.conf"
if [ ! -f "$config_file" ]; then
    config_file=""
fi

database_dir="$HOME/.local/share/plocate"

# updatedb creates the database with 0640 permissions, so to be maximally
# secure we make the directory 0700 before running it, and make the database
# 0600 afterwards just to make sure
/usr/bin/mkdir -p "$database_dir"
/usr/bin/chmod 0700 "$database_dir"
/usr/sbin/updatedb --output="$database_dir/plocate.db" \
    --require-visibility=no ${config_file:+--config-file="$config_file"} "$@"
/usr/bin/chmod 0600 "$database_dir/plocate.db"
