#!/bin/bash

DB_FILE='/var/clearos/disk_usage/duc.db'
LOCK_FILE='/var/clearos/disk_usage/duc.lock'

set -e
(
	flock -w 2 200

	duc index --database=$DB_FILE.temp --exclude /proc --exclude /sys /

	chown root.webconfig $DB_FILE.temp
	chmod 640 $DB_FILE.temp
	mv $DB_FILE.temp $DB_FILE

) 200>$LOCK_FILE

rm -f $LOCK_FILE
