#!/bin/bash
#
# Tweaks for the Light version
echo
echo 'applying VL-Light specific options'

# create fstab entries for optical drives
echo 'looking for optical drives'

if [ -e /dev/sr0 ];then
 if [ ! "$(grep sr0 /etc/fstab)" ];then
 echo 'making fstab entry for sr0'
 echo '/dev/sr0 /media/cdrom auto ro,user,noauto,unhide 0 0' >> /etc/fstab
 fi
fi

if [ -e /dev/sr1 ];then
 if [ ! "$(grep sr1 /etc/fstab)" ];then
 echo 'making fstab entry for sr1'
 echo '/dev/sr1 /media/cdrom1 auto ro,user,noauto,unhide 0 0' >> /etc/fstab
 fi
fi

# if we could get vasm.sh right the first time, we'd save a lot of time
echo modifying vasm.sh
mv /etc/profile.d/vasm.sh.new /etc/profile.d/vasm.sh

# The Fluxbox .desktop file that keeps returning!
rm -f /usr/share/xsessions/Fluxbox.desktop

# clean out services
service -r ifplugd  1>/dev/null 2>&1
service -r portmap  1>/dev/null 2>&1
service -r inetd  1>/dev/null 2>&1
service -r bluetooth  1>/dev/null 2>&1
service -r gpm  1>/dev/null 2>&1
service -r samba  1>/dev/null 2>&1
service -r cups  1>/dev/null 2>&1
service -r fuse  1>/dev/null 2>&1
service -r sshd  1>/dev/null 2>&1
service -r networkmanager  1>/dev/null 2>&1
service -r wicd  1>/dev/null 2>&1


# If user installed ICEWM, re-configure default settings
if [ -e /usr/bin/icewm ];then
 echo "default window manager is IceWM-Session"
 cat <<'EOF'>> /etc/skel/.bashrc
export BROWSER=seamonkey
export EDITOR=leafpad
export EXPLORER=spacefm
#export NETWORK_EXPLORER=konqueror
export AUDIO_PLAYER=smplayer
export VIDEO_PLAYER=smplayer

# Make sure our customised gtkrc file is loaded.
export GTK2_RC_FILES=$HOME/.gtkrc-2.0
EOF
  for i in $(grep home /etc/passwd | cut -d":" -f1 | sed -e s/ftp//);do
   sed -i 's/jwm/icewm-session/' /home/$i/.dmrc
   cat /etc/skel/.bashrc > /home/$i/.bashrc
  done
 sed -i 's/jwm/icewm-session/' /etc/skel/.dmrc
 sed -i 's/jwm/icewm-session/' /root/.dmrc
 cd /etc/X11/xinit
 rm -f xinitrc
 ln -s xinitrc.icewm-session xinitrc
 echo "enabling sudo for wheel users"
 sed -i 's/#%wheel/%wheel/' /etc/sudoers
 echo "enabling services"
 service -s wicd 2345 38
 #service -s samba 4
 service -s cups 4
 service -s fuse 4
 service -s gpm 2
 else
  # If no ICEWM, stay lean
  cd /etc/X11/xinit
  rm -f xinitrc
  ln -s xinitrc.jwm xinitrc
  echo ""
  echo "You have chosen the barebone option."
  service -s gpm 2
  echo "Further setup needs to be done using the command line,"
  echo "enjoy your custom system!"
fi
