#!/bin/bash
# session-setup.sh
#/root/45x11-custom-xrandr-settings

echo $* >/root/session
env >>/root/session

cat <<EOF | tee /etc/samba/.credentials/forum > /dev/null
username=sharing
password=tuxprof
domain=WORKGROUP
EOF
mount /home/forum

SESSION=$(grep Session $HOME/.dmrc)
SESSION_LIGHTDM=${SESSION#Session=}
SESSION_USER=${SESSION_LIGHTDM##*-}

# prévoir une test de connectivité, sinon il sera impossible de démarrer la session en cas d'erreur 
ping -W 2 -c 2 srv.ecole.pdc >/dev/null
if [ $? -eq 0 ]; then  
   mount /home/forum
   mount -t cifs //SRV/homes /home/MaClasse -o rw,vers=2.1,domain=WORKFLOW,user=$SESSION_USER,password=$SESSION_USER,uid=$(id -u $USER),forceuid,gid=$(id -g $USER),forcegid,file_mode=0775,dir_mode=0775
else
   echo "no network" >>/root/session
fi
# ignore les erreurs de réseau
exit 0 