random-commands/cronjob-update-mirrors-search-db

23 lines
688 B
Bash
Executable file

#!/bin/bash
# Update the 'locate' database used for the search backend on slackware.uk.
# Default configuration.
SCANDIR="/data/depository"
DBFILE="/data/sites/slackware.uk/files/repository-search/search.db"
RUNAS_GROUP="depository"
RAND="$$$RANDOM"
if ionice -c3 nice -n 19 sg "$RUNAS_GROUP" -c "/opt/bin/updatedb -l no -o \"$DBFILE.$RAND\" -U \"$SCANDIR\" >/dev/null 2>&1"; then
mv "$DBFILE.$RAND" "$DBFILE" 2>/dev/null || {
printf "%s: %s\\n" "${0##*/}" "failed to move mirrors search database into place" >&2
rm -f "$DBFILE.$RAND"
exit 1
}
else
printf "%s: %s\\n" "${0##*/}" "mirrors search database update failed" >&2
rm -f "$DBFILE.$RAND"
exit 1
fi
exit 0