#!/bin/bash -x
####
# Projeto Escola Livre
# Script para preparar home dos usuarios dos terminais forcando
# o KDE como sessao padrao
# Em 20060206 por Wagner S Dantas <wgdantas@yahoo.com>
# - 20060210: execução do script abaixo apenas pros usuários aluno*. Só deixa
#             configs do .qt (fontes anti-aliasing)
#
###

function is_student(){

   case $USER in
      aluno*) DO=1 ;;
      *) DO=0 ;;
   esac
}

is_student

##### variaveis de ambiente
HOMEDIR=`getent passwd $USER|cut -f 6 -d :`
CLASSEDIR="/home/var/ltsp_setup/classe"

echo "res ($USER:$HOMEDIR) = $DO" > /tmp/ltsp_login.log

##### qt configs
QTCONFIGBASE="$CLASSEDIR/ponto_qt-modelo" #usado para fontes anti-aliasing
HOMEQTCONFIG="$HOMEDIR/.qt"

rm -rf $HOMEQTCONFIG
cp -a $QTCONFIGBASE $HOMEQTCONFIG
chown -R $USER.$USER $HOMEQTCONFIG

##### outras configs (usuarios aluno*)
if [ $DO -eq 1 ]; then
      
   ##### menu configs
   HOMECONFIG="$HOMEDIR/.config"
   HOMELOCAL="$HOMEDIR/.local"
   MENUCONFIG="$HOMECONFIG/menus"
   MENUCONFIGBASE="$CLASSEDIR/ponto_config_barra_menus-modelo"
   LOCALCONFIGBASE="$CLASSEDIR/ponto_local-modelo"
   
   ##### kde configs
   KDECONFIGBASE="$CLASSEDIR/ponto_kde-modelo"
   KDECONFIGRCBASE="$CLASSEDIR/ponto_kderc-modelo"
   HOMEKDECONFIG="$HOMEDIR/.kde"
   HOMEKDECONFIGRC="$HOMEDIR/.kderc"
   
   ##### outras configs
   #WORDTRANSBASE="$CLASSEDIR/ponto_wordtrans-modelo"
   #HOMEWORDTRANS="$HOMEDIR/.wordtrans"

   #if [ ! -d $HOMEWORDTRANS ]; then
   #   cp -a $WORDTRANSBASE $HOMEWORDTRANS
   #   chown -R $USER.$USER $HOMEWORDTRANS
   #fi

   if [ ! -d  $HOMECONFIG ]; then
      mkdir $HOMECONFIG
      chmod 755 $HOMECONFIG
      chown $USER.$USER $HOMECONFIG
   fi
  
   rm -rf $MENUCONFIG
   rm -rf $HOMELOCAL
   rm -rf $HOMEKDECONFIG
   rm -f $HOMEKDECONFIGRC
   
   #### copiando configs de menu
   mkdir  $MENUCONFIG
   cp -a $MENUCONFIGBASE $MENUCONFIG/applications-kmenuedit.menu
   #chmod 755 $MENUCONFIG
   chown -R $USER.$USER $MENUCONFIG
   
   mkdir $HOMELOCAL
   cp -a $LOCALCONFIGBASE/* $HOMELOCAL
   #chmod 755 $HOMELOCAL
   chown -R $USER.$USER $HOMELOCAL
   
   #### copiando configs do KDE
   cp -a $KDECONFIGBASE $HOMEKDECONFIG
   chown -R $USER.$USER $HOMEKDECONFIG
   
   cp -a $KDECONFIGRCBASE $HOMEKDECONFIGRC
   chown -R $USER.$USER $HOMEKDECONFIGRC
   
fi

### Projeto Escola Livre
# Preparar terminal para uso de dispositivos remotos
# http://wiki.ltsp.org/twiki/bin/view/Ltsp/LocalMedia
#/usr/local/bin/LDA-setup.sh
###

