#!/bin/sh
# --- SDE-COPYRIGHT-NOTE-BEGIN ---
# This copyright note is auto-generated by ./scripts/Create-CopyPatch.
#
# Filename: package/.../cron/00-updates.cron
# Copyright (C) 2006 The OpenSDE Project
# Copyright (C) 2004 - 2006 The T2 SDE Project
# Copyright (C) 1998 - 2003 Clifford Wolf
#
# More information can be found in the files COPYING and README.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; version 2 of the License. A copy of the
# GNU General Public License can be found in the file COPYING.
# --- SDE-COPYRIGHT-NOTE-END ---

exec 2>&1

for kver in $( ls -1d /lib/modules/*/ 2> /dev/null | cut -d/ -f4 ); do
	echo "Running depmod ($kver) ..."
	if [ -f /boot/System.map_$kver ]; then
		depmod -a -e -F /boot/System.map_$kver $kver 2>&1 | tee /tmp/depmod.$$
	else
		depmod -a $kver 2>&1 | tee /tmp/depmod.$$
	fi
	warn=`grep "warnings" /tmp/depmod.$$ | wc -l`
	echo "   produced $warn warnings."
	rm -r /tmp/depmod.$$
done

echo "Running ldconfig ..."
ldconfig

echo "Running makewhatis ..."
makewhatis

echo "Running updatedb ..."
updatedb "--prunepaths=/tmp /var/tmp /root /proc /sys /dev /home /user /mnt"

echo "Recreate info dir ..."
rm -f /usr/share/info/dir
find /usr/share/info /opt/*/info/ -type f  2>/dev/null |
grep -v -E -e "/dir$|-[0-9]+$" |
while read x ; do
	{ install-info "--info-dir=/usr/share/info" $x 2>&1 ; } |
		egrep -v 'no info dir entry in|already exists, for file'
done

echo