#!/bin/sh
# Description: Launch this Mandrake Scripts every time.
# (c) MandrakeSoft, Chmouel Boudjnah <chmouel@mandrakesoft.com>
. /etc/rc.d/init.d/functions

[ -e /etc/sysconfig/system ] && . /etc/sysconfig/system
[ -e /etc/sysconfig/i18n ] && . /etc/sysconfig/i18n

# Build KdmSession
#[ -x /usr/sbin/fndSession ] && {
#       action "Building Window Manager Sessions" /usr/sbin/fndSession
#}

# Optimisation of Hard drive.
#if grep -qi opti /proc/cmdline || [ -n "$HDPARM" ]; then
#if [ -x /sbin/hdparm ];then
#LIST_HD=$(grep '^hd.:' /var/log/dmesg|\
#	grep -ivE '(CD.*ROM|FLOPPY|TAPE|STATUS)'|cut -d: -f1|sort|uniq)
#
#	if grep -i nohdparm /proc/cmdline >/dev/null ; then
#		action "Hard Drive optimisations disabled" \
#		echo ""
#	else
#	for i in $LIST_HD;do
#	action "Starting Hard Drive optimisations for $i" \
#		hdparm -q -c1 -q -A1 -q -m16 -q -d1 /dev/$i
#	done
#	fi
#fi
#fi

# Disabling supermount if not here
if ! grep -i linuxfix /proc/cmdline >/dev/null ; then
    if grep -q '^\/.*supermount.*' /etc/fstab && [ ! -e /lib/modules/$(uname -r)/fs/supermount.o ] && [ -x /usr/bin/perl ];then
	action "Disabling Supermount" /usr/sbin/supermount -i disable
    fi
fi    

# check if /etc/resolv.conf exist - if not creates it
[ -f /etc/resolv.conf ] || {
               touch /etc/resolv.conf
}

# check if /mnt/cdrom , /mnt/floppy and /mnt/disk are here - if not create them
[ -d /mnt/cdrom ] || {
       action "Creating /mnt/cdrom" mkdir -p /mnt/cdrom
}

[ -d /mnt/floppy ] || {
     action "Creating /mnt/floppy" mkdir -p /mnt/floppy
}

#[ -d /mnt/disk ] || {
#    action "Creating /mnt/disk" mkdir -p /mnt/disk
#}

# try to insmod vfat
/sbin/modprobe vfat &> /dev/null

# Only for patched shadow_utils!!!
# For RE only!!!
# set template for skel
#
NLS_SKEL_DIR="/etc/skel.`expr substr $LANG 1 2`"
if [ -d $NLS_SKEL_DIR ]; then
  useradd -D -k $NLS_SKEL_DIR &> /dev/null
fi

# 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
