Rev 136 | Rev 140 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | Download | RSS feed
#!/bin/bash
#
# Fix things during bootup - run last
# called at the end of /etc/rc.d/rc.local
#
# Urs Beyerle, PSI
#
### -----------------------------------------------------------
### definitions
### -----------------------------------------------------------
# dir of mounted live system: /$MOUNTDIR/live
MOUNTDIR=livecd
# source functions
. /$MOUNTDIR/live/liblinuxlive
. /etc/init.d/functions
# defaults for xorg.conf
XORG_CONF=/etc/X11/xorg.conf
HSYNC_DEFAULT="30.0-80.0"
VSYNC_DEFAULT="50.0-90.0"
SCREEN_DEFAULT="1400x1050"
MODES_DEFAULT='"2048x1536" "1920x1200" "1600x1200" "1400x1050" "1280x1024" "1280x960" "1280x800" "1152x864" "1152x768" "1024x768" "800x600" "640x480"'
### -----------------------------------------------------------
### Get boot parameters
### -----------------------------------------------------------
# root on NFS?
NFSROOT=$( cmdline_value nfsroot )
# NFS Server
NFSSERVER=$( echo $NFSROOT | cut -d":" -f1 )
# no local user?
NOLOCAL=$( cmdline_parameter nolocal )
# no root user?
NOROOT=$( cmdline_parameter noroot )
# no localadmin?
NOADMIN=$( cmdline_parameter noadmin )
LocalAdminGroup=localadmin
# set password
PASSWD=$( cmdline_value passwd )
[ ! $PASSWD ] && PASSWD=$( cmdline_value pw )
# no password = empty password
NOPASSWD=$( cmdline_parameter nopasswd )
# keyboard layout (kb= or keyboard=)
KEYBOARD=$( cmdline_value keyboard )
KB=$( cmdline_value kb )
# PSI setup?
PSI=$( cmdline_parameter psi )
# cups server
CUPS=$( cmdline_value cups )
# failsafe X server
SIMPLEX=$( cmdline_parameter simplex )
# NVIDIA driver
NVIDIA=$( cmdline_parameter nvidia )
[ "$XDRIVER" = "nvidia" ] && NVIDIA=nvidia
# force NO NVIDIA driver - will overwite NVIDIA option
NONVIDIA=$( cmdline_parameter nonvidia )
# VESA driver
VESA=$( cmdline_parameter vesa )
# force to use a video driver ?
XDRIVER=$( cmdline_value xdriver )
# Xserver configurations
HSYNC=$( cmdline_value hsync )
VSYNC=$( cmdline_value vsync )
SCREEN=$( cmdline_value screen )
# no SWAP
NOSWAP=$( cmdline_parameter noswap )
# should we auto mount all found devices?
AUTOMOUNT=$( cmdline_parameter automount )
if [ $AUTOMOUNT ]; then
MOUNTOPT="auto,users"
else
MOUNTOPT="noauto,users,ro"
fi
# folder where we find data which was previously stored
# (can be on an usbstick or harddisk partition)
SAVEFOLDER=SL_LIVECD
# local home partition?
# (e.g. /dev/hda1, /dev/hda1:/my_home)
HOMELOCAL=$( cmdline_value home )
# fast booting?
FASTBOOT=$( cmdline_parameter fastboot )
# start afs?
AFS=$( cmdline_parameter afs )
# or force no afs
[ $( cmdline_parameter noafs ) ] && AFS=""
# turn of sound (volume=0)
NOSOUND=$( cmdline_parameter nosound )
# local user name?
LOCALUSER=$( cmdline_value user )
# hostname?
HOSTNAME=$( cmdline_value hostname )
# do we have defined a configuration directory?
CONFIG=$( cmdline_value config )
# do not udpate fstab?
NOFSTAB=$( cmdline_parameter nofstab )
# kde/gnome as desktop
GNOME=$( cmdline_parameter gnome )
KDE=$( cmdline_parameter kde )
# do no fixes (useful for debugging)
NOFIX=$( cmdline_parameter nofix )
# do not start network
NONET=$( cmdline_parameter nonet )
### -----------------------------------------------------------
### Functions
### -----------------------------------------------------------
reload_soundmodule() {
### unload/load sound module for snd-card-X (timing problem?)
if [ ! $NOFIX ]; then
rpm -q alsa-lib | grep el5 >/dev/null
if [ "$?" = "0" ]; then
# disable kernel messages
echo "0" > /proc/sys/kernel/printk
sound_modules=$( grep snd-card- /etc/modprobe.conf | awk ' $1 ~ /alias/ { print $3 }' | tr - _ )
for module in $sound_modules; do
lsmod | awk '{ print $1 }' | grep $module >/dev/null 2>&1
if [ "$?" = "0" ]; then
rmmod $module >/dev/null 2>&1
modprobe $module >/dev/null 2>&1
fi
done
# enable kernel messages
echo "6" > /proc/sys/kernel/printk
fi
fi
}
### -----------------------------------------------------------
### Improved hardware detection
### -----------------------------------------------------------
### Improved graphic card detection
if [ ! $SIMPLEX ] && [ ! $NOFIX ]; then
### Intel Mobile 915GM
lspci | grep -q VGA.*Intel.*Mobile.*915GM
if [ "$?" = "0" ]; then
I915GM=i915gm
[ $XDRIVER ] || XDRIVER=i810
fi
### Intel Mobile 855GM
lspci | grep -q VGA.*Intel.*855GM
if [ "$?" = "0" ]; then
I855GM=i855gm
fi
fi
### -----------------------------------------------------------
### Main
### -----------------------------------------------------------
### try to load fuse kernel module
modprobe fuse 2>/dev/null
### reload sound module (first time)
reload_soundmodule
### activate SWAP
# delete all swap lines in fstab
sed -i -e "/ swap /d" /etc/fstab
# search for swap partition
fdisk -l > /var/log/fdisk
swap_part=$( fdisk -l 2>/dev/null | grep -i "Linux swap" \
| grep "^/dev/" | cut -f 1 -d " " | head -1 )
# add to /etc/fstab and activate SWAP
if [ $swap_part ] && [ ! $NOSWAP ]; then
echo "$swap_part swap swap defaults 0 0" >>/etc/fstab
# activate SWAP
swapoff -a
swapon -a -e
fi
### MAC Address of eth0
MAC_ETH0=$( ifconfig | grep eth0 | awk '{print $5}' )
### Get CONFIG_FOLDER for this machine from NFS Server (if existing)
# and copy it to /$MOUNTDIR
if [ $NFSSERVER ] && [ $CONFIG ]; then
mkdir -p /mnt/config
echo "Search for configuration files on the server ..."
/etc/init.d/portmap start >/dev/null
mount -t nfs $NFSSERVER:$CONFIG /mnt/config 2>/dev/null
if [ "$?" != "0" ]; then
echo "Could not mount $NFSSERVER:$CONFIG."
else
if [ -d /mnt/config/$MAC_ETH0 ]; then
CONFIG_FOLDER=/$MOUNTDIR/config
mkdir -p $CONFIG_FOLDER
cp -a /mnt/config/$MAC_ETH0/* /$CONFIG_FOLDER/ 2>/dev/null
if [ "$?" != "0" ]; then
echo "Could not get $NFSSERVER:$CONFIG/$MAC_ETH0"
CONFIG_FOLDER=""
else
echo "Found configuration files on the server."
fi
fi
umount /mnt/config
fi
/etc/init.d/portmap stop >/dev/null
fi
### search for partitions and update fstab
### and look for $SAVEFOLDER (previously stored data)
if [ ! $FASTBOOT ] && [ ! $NOFSTAB ]; then
echo "Update /etc/fstab ..."
# disable kernel messages during mount/unmount
echo 0 > /proc/sys/kernel/printk
DEVICES=$( list_partition_devices )
for DEVICE in $DEVICES; do
# try to mount the device and unmount it.
# If OK, we can add it to fstab
DEV=$( echo $DEVICE | cut -d"/" -f 3 )
if [ $DEV ]; then
mkdir -p /mnt/$DEV
mount $DEVICE /mnt/$DEV >/dev/null 2>&1
# search for $SAVEFOLDER
if [ -d /mnt/$DEV/$SAVEFOLDER ]; then
FOUND_RESTORE_DEV=/dev/$DEV
echo "Found folder '$SAVEFOLDER' on $FOUND_RESTORE_DEV"
fi
# unmount again
umount /mnt/$DEV >/dev/null 2>&1
# if sucsessful add to fstab, if not already done
if [ "$?" = "0" ]; then
grep -q "^$DEVICE " /etc/fstab
if [ "$?" != "0" ]; then
echo -e "$DEVICE \t /mnt/$DEV \t auto \t $MOUNTOPT,suid,dev,exec 0 0" >> /etc/fstab
fi
else
rmdir /mnt/$DEV 2>/dev/null
fi
fi
done
# enable kernel messages again
echo 6 > /proc/sys/kernel/printk
fi
### if $SAVEFOLDER found, set $CONFIG_FOLDER and mount $FOUND_RESTORE_MNT
if [ $FOUND_RESTORE_DEV ]; then
FOUND_RESTORE_MNT=$( grep "^$FOUND_RESTORE_DEV " /etc/fstab | awk '{ print $2 }' )
CONFIG_FOLDER=$FOUND_RESTORE_MNT/$SAVEFOLDER
echo "Will restore data from $CONFIG_FOLDER"
mount $FOUND_RESTORE_MNT
fi
### source the file "config", if found in $CONFIG_FOLDER
if [ -f $CONFIG_FOLDER/config ]; then
. $CONFIG_FOLDER/config
fi
### do we have a shadow/passwd file in $FOUND_FOULDER
if [ -r $CONFIG_FOLDER/passwd.tar.gz ] && [ -r $CONFIG_FOLDER/shadow.tar.gz ]; then
# we do not need a password for local user and root
NOLOCAL=nolocal
NOROOT=noroot
fi
### set local user name and default hostname
if [ $PSI ]; then
[ $LOCALUSER ] || LOCALUSER=l_psi
DEFAULT_HOSTNAME=psi
else
[ $LOCALUSER ] || LOCALUSER=sluser
DEFAULT_HOSTNAME=slinux
fi
### check for xorg.conf in CONFIG_FOLDER
if [ -r $CONFIG_FOLDER/xorg.conf ]; then
cp -af $CONFIG_FOLDER/xorg.conf $XORG_CONF
if [ "$?" = "0" ]; then
echo "Saved xorg.conf file found."
XDRIVER=""
HAVE_XORG_CONF="yes"
fi
fi
### use vesa driver?
if [ $VESA ]; then
echo "Force to use VESA driver!"
video_driver="--set-driver=vesa"
else
video_driver=""
fi
### force an other video driver?
if [ $XDRIVER ]; then
echo "Force to use $XDRIVER driver!"
video_driver="--set-driver=$XDRIVER"
fi
### configure Xserver
if [ -x /usr/bin/system-config-display ]; then
echo "Configure Xserver:"
if [ ! $HAVE_XORG_CONF ]; then
if [ ! $SIMPLEX ]; then
# default values
[ ! $HSYNC ] && HSYNC="$HSYNC_DEFAULT"
[ ! $VSYNC ] && VSYNC="$VSYNC_DEFAULT"
[ ! $SCREEN ] && SCREEN="$SCREEN_DEFAULT"
# run system-config-display
system-config-display \
--reconfig \
-v \
--set-resolution=$SCREEN \
--set-hsync=$HSYNC \
--set-vsync=$VSYNC \
$video_driver | grep Trying
# system-config-display in SL5 does not work nicely :-(
# e.g. No Monitor Section
# add Monitor Section and add Monitor0 to Screen Section
grep -q Monitor $XORG_CONF
if [ "$?" != "0" ]; then
echo "Section \"Monitor\"" >> $XORG_CONF
echo -e "\tIdentifier \"Monitor0\"" >> $XORG_CONF
echo -e "\tHorizSync $HSYNC" >> $XORG_CONF
echo -e "\tVertRefresh $VSYNC" >> $XORG_CONF
echo -e "\tOption \"dpms\"" >> $XORG_CONF
echo -e "EndSection" >> $XORG_CONF
sed -i "s|Device \"Videocard0\"|Device \"Videocard0\"\n\tMonitor \"Monitor0\"|" $XORG_CONF
fi
# add Modes for $SCREEN, if not yet there
grep -q Modes $XORG_CONF
if [ "$?" != "0" ]; then
modeline=$( echo ${MODES_DEFAULT} | sed "s|.*\"$SCREEN|\"$SCREEN|" )
if [ "$modeline" ]; then
sed -i "s|\tDepth.*|\tDepth 24\n\t\tModes $modeline|" $XORG_CONF
fi
fi
# simple Xserver configuration.
else
echo "Use simple Xserver configuration."
system-config-display --noui --reconfig -v | grep Trying
fi
fi
fi
### enable nvidia driver
if [ $NVIDIA ] && [ ! $NONVIDIA ]; then
# serach for Nvidia Video Card
/sbin/lspci | grep VGA | grep -i -q nvidia
if [ "$?" = "0" ]; then
# nvidia-x11-drv installed?
which nvidia-xconfig >/dev/null 2>&1
if [ "$?" = "0" ]; then
echo "Enable nvidia driver."
# set driver to nv in case it's only vesa
sed -i 's|"vesa"|"nv"|' /etc/X11/xorg.conf
# configure for nvidia driver
nvidia-xconfig >/dev/null 2>&1
nvidia-config-display enable
fi
fi
fi
### set special video driver options for Intel Mobile
# (external VGA output: Clone)
if [ $I915GM ] || [ $I855GM ]; then
sed -e "/Section[ \t]*\"Device\"/,/EndSection/{
/^[ \t]*Option[ \t]*\"MonitorLayout\"/d
/^[ \t]*Option[ \t]*\"Clone/d
/EndSection/i\\
Option \"MonitorLayout\" \"CRT,LFP\"\\
Option \"Clone\" \"1\"\\
Option \"CloneRefresh\" \"60\"
}" -i $XORG_CONF
fi
# Set BoardName for Intel 915GM
if [ $I915GM ]; then
sed -i 's/BoardName.*VESA driver.*/BoardName "Intel 915"/' $XORG_CONF
fi
### parameter KB = KEYBOARD
KEYBOARD=$KB
### ask user for keyboard layout if no keyboard given
if [ -x /usr/bin/system-config-keyboard ]; then
if [ ! $KEYBOARD ]; then
MORE_LAYOUTS="more..."
keytables="U.S...........(us) \
Swiss-German..(sg-latin1) \
Swiss-French..(fr_CH-latin1) \
German........(de-latin1) \
Japanese......(jp106) \
$MORE_LAYOUTS"
PS3="-> "
echo
echo "Please choose keyboard layout (type 1-6):"
select KEYBOARD in $keytables;
do
case $KEYBOARD in
*)
# extract keyboard layout string from $KEYBOARD
KEYBOARD=${KEYBOARD##*(}
KEYBOARD=${KEYBOARD%%)}
break
;;
esac
done
fi
fi
### set keyboard
if [ -x /usr/bin/system-config-keyboard ]; then
if [ "$KEYBOARD" = "$MORE_LAYOUTS" ]; then
system-config-keyboard --text
else
echo -n "Set keyboard to '$KEYBOARD', please wait ... "
system-config-keyboard --noui $KEYBOARD >/dev/null 2>&1
echo "done."
fi
echo
fi
### update AFS users and SEPP (only for PSI)
if [ $PSI ] && [ $AFS ]; then
echo "Update AFS users..."
[ -x /afs/psi.ch/sys/common/update_user.pl ] && /afs/psi.ch/sys/common/update_user.pl >/dev/null 2>&1 &
if [ -d /usr/pack ]; then
echo "Update SEPP links..."
[ -x /afs/psi.ch/sys/common/update_sepp.pl ] && /afs/psi.ch/sys/common/update_sepp.pl >/dev/null 2>&1 &
fi
echo
fi
### create local user, if "nolocal" is not set
if [ ! $NOLOCAL ]; then
user=$LOCALUSER
# execute useradd twice, to make it work (don't know why)
if [ $PSI ] && [ ! $NOADMIN ]; then
userdel -r $user 2>/dev/null
useradd -G $LocalAdminGroup $user 2>/dev/null
userdel -r $user 2>/dev/null
useradd -G $LocalAdminGroup $user
else
userdel -r $user 2>/dev/null
useradd $user 2>/dev/null
userdel -r $user 2>/dev/null
useradd $user
fi
# only for PSI: change users's group to GID=UID+50000
if [ $PSI ]; then
uid=$( id -u $user )
old_gid=$( id -g $user )
new_gid=$(( $old_gid + 50000 ))
# fix /etc/group
sed -i "s/${user}:x:${old_gid}:/${user}:x:${new_gid}:/" /etc/group
# fix /etc/passwd
sed -i "s/${user}:x:${uid}:${old_gid}:/${user}:x:${uid}:${new_gid}:/" /etc/passwd
# fix perm of /home/${user)
chgrp -R $user /home/${user}
fi
fi
### copy special files for PSI user l_psi
if [ $PSI ] && [ ! $NOLOCAL ]; then
find /usr/share/${LOCALUSER}/ -maxdepth 1 -mindepth 1 2>/dev/null | \
while read dir; do
cp -a $dir /home/${LOCALUSER}/
done
# set owner
chown -R ${LOCALUSER}.${LOCALUSER} /home/${LOCALUSER}
fi
### autostart kmix and krandrtray in KDE
if [ ! $NOLOCAL ]; then
mkdir -p /home/${LOCALUSER}/.kde/Autostart
cp -a /usr/share/applications/kde/krandrtray.desktop /home/${LOCALUSER}/.kde/Autostart 2>/dev/null
cp -a /usr/share/applications/kde/kmix.desktop /home/${LOCALUSER}/.kde/Autostart 2>/dev/null
chown -R ${LOCALUSER}.${LOCALUSER} /home/${LOCALUSER}/.kde/Autostart
fi
### first set empty password
if [ ! $NOROOT ]; then
sed -i "s|^root:.*|root::12345:0:99999:1:::|" /etc/shadow
fi
if [ ! $NOLOCAL]; then
sed -i "s|^$LOCALUSER:.*|$LOCALUSER::12345:0:99999:1:::|" /etc/shadow
fi
### set password for root and local user
if [ ! $NOPASSWD ]; then
if [ ! $NOROOT ] || [ ! $NOLOCAL ]; then
echo -n "Set password for "
if [ ! $NOROOT ]; then
echo -n "'root' "
fi
if [ ! $NOROOT ] && [ ! $NOLOCAL ]; then
echo -n "and "
fi
if [ ! $NOLOCAL ]; then
echo -n "local user '$user' "
fi
echo
echo "or hit return for empty password."
if [ ! $NOLOCAL ]; then
echo "Login as local user '$user' with this password."
fi
echo
# ask for password, if not yet given by $PASSWD
if [ ! $PASSWD ]; then
echo -n "Password: "
read -s PASSWD
echo
fi
# set password - or - set empty password
if [ ! $NOROOT ] && [ "$PASSWD" ]; then
echo $PASSWD | passwd --stdin root >/dev/null
fi
if [ ! $NOLOCAL] && [ "$PASSWD" ]; then
echo $PASSWD | passwd --stdin $user >/dev/null
fi
echo
fi
fi
### try to get hostname from DNS, if not yet defined
if [ ! $HOSTNAME ]; then
echo "Try to get hostname from DNS ..."
IP=$( /sbin/ip add show dev eth0 2>/dev/null | grep "inet " | cut -d" " -f6 | sed 's|/.*||' )
if [ "$IP" = "" ]; then
IP=$( /sbin/ip add show dev eth1 2>/dev/null | grep "inet " | cut -d" " -f6 | sed 's|/.*||' )
fi
if [ "$IP" != "" ]; then
host -W 1 $IP >/dev/null 2>&1
if [ "$?" = "0" ]; then
HOSTNAME=$( host -W 1 $IP | cut -d" " -f 5 | cut -d"." -f 1 )
if [ "$HOSTNAME" = "3(NXDOMAIN)" ]; then
HOSTNAME=$DEFAULT_HOSTNAME
fi
if [ "$HOSTNAME" = "no" ]; then
HOSTNAME=$DEFAULT_HOSTNAME
fi
fi
fi
fi
### define default hostname, if $HOSTNAME is still not yet set
if [ ! $HOSTNAME ]; then
HOSTNAME=$DEFAULT_HOSTNAME
fi
### set hostname
export HOSTNAME=$HOSTNAME
hostname $HOSTNAME
sed -i "s/HOSTNAME=.*/HOSTNAME=${HOSTNAME}/" /etc/sysconfig/network
if [ $PSI ]; then
sed -i "s/hostname=.*/hostname=${HOSTNAME}.psi.ch/" /etc/ssmtp/ssmtp.conf
sed -i "s/HOSTNAME=.*/HOSTNAME=${HOSTNAME}/" /etc/sysconfig/psi
fi
for iface in eth0 eth1 eth2 eth3; do
if [ -e /etc/sysconfig/network-scripts/ifcfg-${iface} ]; then
echo "DHCP_HOSTNAME=${HOSTNAME}" >> /etc/sysconfig/network-scripts/ifcfg-${iface}
fi
done
echo "Hostname set to: $HOSTNAME"
echo
### set cups server
if [ $CUPS ]; then
sed -i "s|.*ServerName .*|ServerName $CUPS|" /etc/cups/client.conf
grep -q ServerName /etc/cups/client.conf || echo "ServerName $CUPS" >> /etc/cups/client.conf
fi
### some magic: just access this file in order that it can be sourced later
ls -lag /etc/X11/xinit/xinitrc-common >/dev/null 2>&1
### set keyboard for rdesktop
if [ -e $XORG_CONF ]; then
grep -q de_CH $XORG_CONF && RDESKTOP_OPT="-k de-ch"
grep -q fr_CH $XORG_CONF && RDESKTOP_OPT="-k fr-ch"
grep -q jp106 $XORG_CONF && RDESKTOP_OPT="-k ja"
fi
if [ "$RDESKTOP_OPT" ]; then
echo "alias rdesktop='rdesktop $RDESKTOP_OPT'" > /etc/profile.d/rdesktop.sh
echo "export RDESKTOP_OPT='$RDESKTOP_OPT'" >> /etc/profile.d/rdesktop.sh
chmod 755 /etc/profile.d/rdesktop.sh
fi
### run setup script, if found in $CONFIG_FOLDER on $FOUND_RESTORE_MNT
if [ -r $CONFIG_FOLDER/setup ]; then
CONFIG_FOLDER=$CONFIG_FOLDER bash $CONFIG_FOLDER/setup
fi
### umount $FOUND_RESTORE_MNT
if [ $FOUND_RESTORE_MNT ]; then
echo "Unmount $FOUND_RESTORE_MNT"
umount $FOUND_RESTORE_MNT 2>/dev/null
sleep 3
fi
### local home partition?
if [ $HOMELOCAL ]; then
mv /home /home.old
mkdir -p /mnt/home_par
# which partition? which folder?
HOMEPAR=$( echo $HOMELOCAL | cut -d":" -f1 )
HOMEDIR=$( echo $HOMELOCAL | grep ":" | cut -d":" -f2 )
umount $HOMEPAR 2>/dev/null
# mount it with option noatime, healthy for USB flash drives
mount -o noatime -rw $HOMEPAR /mnt/home_par 2>/dev/null
if [ "$?" != "0" ]; then
echo "ERROR: Could not mount read/write $HOMEPAR"
umount $HOMEPAR >/dev/null 2&>1
mv /home.old /home
else
echo "$HOMEPAR mounted on /mnt/home_par"
# link to new home
ln -s /mnt/home_par/$HOMEDIR /home
if [ ! -d /mnt/home_par/$HOMEDIR ]; then
echo "$HOMELOCAL not found on $HOMEPAR"
echo mkdir -p /mnt/home_par/$HOMEDIR
if [ "$?" != "0" ]; then
echo "ERROR: Could not create $HOMELOCAL on $HOMEPAR"
umount $HOMEPAR >/dev/null 2&>1
rm -f /home
mv /home.old /home
else
echo "Folder $HOMEDIR created on $HOMEPAR"
fi
fi
if [ -d /mnt/home_par/$HOMEDIR ]; then
echo "/home is linked to /mnt/home_par${HOMEDIR}"
# copy files from /home.old to /home, which are not yet there
/bin/cp -a -i --reply=no /home.old/* /home/
rm -rf /home.old
fi
fi
sleep 2
fi
### mount all if AUTOMOUNT set
if [ $AUTOMOUNT ]; then
mount -a
fi
### unmute all mixers and set volumes
if [ -x /usr/bin/set-volume ]; then
if [ $NOSOUND ]; then
/usr/bin/set-volume 0 > /var/log/set-volume.log 2>&1 &
else
/usr/bin/set-volume 60 > /var/log/set-volume.log 2>&1 &
fi
fi
### set kde or gnome as desktop
if [ $KDE ]; then
sed -i "/^DESKTOP=.*/d" /etc/sysconfig/desktop 2&>/dev/null
echo "DESKTOP=KDE" >> /etc/sysconfig/desktop
fi
if [ $GNOME ]; then
sed -i "/^DESKTOP=.*/d" /etc/sysconfig/desktop 2&>/dev/null
echo "DESKTOP=GNOME" >> /etc/sysconfig/desktop
fi
### reload sound module (second time)
reload_soundmodule
### bring up all network interfaces (useful to enable WLAN devices)
if [ ! $NONET ]; then
devices=$( ls /etc/sysconfig/network-scripts/ifcfg-* \
| sed "s|/etc/sysconfig/network-scripts/ifcfg-||" | grep -v lo )
for device in $devices; do
ifconfig $device up > /dev/null 2>&1 &
done
fi