#!/bin/bash
# Description: Launch diverses Mandrake Scripts on boot.
# (c) MandrakeSoft, Chmouel Boudjnah <chmouel@mandrakesoft.com>
# 	$Id: mandrake_everytime,v 1.13 2002/02/18 14:46:18 chmouel Exp $	

. /etc/rc.d/init.d/functions

[ -e /etc/sysconfig/system ] && . /etc/sysconfig/system

# Build KdmSession
[ -x /usr/sbin/fndSession ] && {
       action "Building Window Manager Sessions" /usr/sbin/fndSession
}

# Disabling supermount if not here
if [[ $(uname -m) != sparc*  ]];then
    if grep -q '^\/.*supermount.*' /etc/fstab && \
	! grep -q '[[:space:]]supermount$' /proc/filesystems  && \
	! modprobe -n supermount >/dev/null 2>/dev/null && [ -x /usr/bin/perl ];then
	action "Disabling Supermount" /usr/sbin/supermount -i disable
    fi
fi

# setup eth* (without configuring it) interfaces before the
# hotplug/pcmcia started so we are sure that what we have configured
# in /etc/modules.conf get the device we have affected.  NB: We assume
# max 10 interfaces for speed reason.
i=0
while [[ $i != 10 ]];do
		/sbin/ifconfig eth$i 2>/dev/null >/dev/null
		(( i++ ))
done
unset i

#Clean up Tmp.
if [ -n "$CLEAN_TMP" ] && [ "$CLEAN_TMP" -ge 1 ];then
    ( 
	TEXPR="! -ctime -$CLEAN_TMP"
	echo -n "Clean-up /tmp directory: "
	cd /tmp && \
	    find . -xdev \
	    $TEXPR \
	    ! -name . \
	    ! \( -name lost+found -uid 0 \) \
	    ! \( -name quota.user -uid 0 \) \
	    ! \( -name quota.group -uid 0 \) \
	    -depth -print | while read i; do [ -d "$i" ] && rmdir "$i" 2>/dev/null ; rm -f "$i" 2>/dev/null; done
       	if [ "$?" = "0" ];then echo_success;else echo_failure;fi
	echo
    )
    rm -f /tmp/.X*-lock
    rm -f /tmp/esrv*
    rm -f /tmp/kio*
    rm -rf /tmp/.esd*
    rm -rf /tmp/orbit-*
    rm -rf /tmp/ssh-*
    rm -rf /tmp/ksocket-*
fi

# check if /etc/resolv.conf exist - if not creates it
[ -f /etc/resolv.conf ] || {
               touch /etc/resolv.conf
}

[ -d /mnt/disk ] || {
    action "Creating /mnt/disk" mkdir -p /mnt/disk
}

# Now that we have all of our basic modules loaded and the kernel going,
# let's dump the syslog ring somewhere so we can find it later
dmesg > /var/log/dmesg
