#!/bin/bash
#Christophe Deze - Rectorat de Nantes
#script d'integration de station ubuntu 8.10 sur un scribe NG
#testé avec Scribe 2.2
#et ubuntu 8.10
# beta 0.000000000001
#IP_SCRIBE="172.17.212.1"
IP_SCRIBE=""
secondes=`date +%s`
#export http_proxy=""
echo "Donnez l'ip du scribe par défaut : $IP_SCRIBE)"
read ip
if [ -z $ip ]
then
IP_SCRIBE=$ip
fi
#rendre debconf silencieux
export DEBIAN_FRONTEND="noninteractive"
export DEBIAN_PRIORITY="critical"
#installation des paquets necessaires
apt-get update
apt-get install -y nfs-common portmap smbfs libpam-mount ldap-utils libpam-ldap
#on remet debconf dans sa conf initiale
export DEBIAN_FRONTEND="dialog"
export DEBIAN_PRIORITY="high"
#Fichiers de config
# /etc/ldap.conf
cp /etc/ldap.conf ldap.conf.$secondes
echo "
# /etc/ldap.conf
host $IP_SCRIBE
base o=gouv, c=fr
" > /etc/ldap.conf
## /etc/ldap.conf
cp /etc/nsswitch.conf nsswitch.conf.$secondes
sed -i "s/passwd: compat/passwd: compat ldap/g" /etc/nsswitch.conf
sed -i "s/group: compat/group: compat ldap/g" /etc/nsswitch.conf
sed -i "s/shadow: compat/shadow: compat ldap/g" /etc/nsswitch.conf
#copie du home de l'utilisateur local dans opt
cp /etc/passwd /etc/passwd.$secondes
for file in `ls -d /home/*/ | xargs -l basename`; do
cp -aR /home/$file /opt/
sed -i "s/home\/$file/opt\/$file/g" /etc/passwd
done
#/etc/fstab pour le montage nfs des homes
grep "$IP_SCRIBE:/home" /etc/fstab >/dev/null; if [ $? == 0 ];then echo "Ok"; else echo "$IP_SCRIBE:/home /home nfs rw 0 0" >> /etc/fstab ;fi
#creation des fichiers pour scribe
echo "account sufficient pam_ldap.so use_first_pass" >> /etc/pam.d/scribe-account
echo "auth optional pam_group.so
auth optional pam_mount.so use_first_pass
auth sufficient pam_ldap.so use_first_pass" >> /etc/pam.d/scribe-auth
echo "session optional pam_mount.so use_first_pass
session optional pam_mkhomedir.so" >> /etc/pam.d/scribe-session
#/etc/pam.d/login
cp /etc/pam.d/login login.$secondes
echo "
@include scribe-account
@include scribe-session
@include scribe-auth" >> /etc/pam.d/login
#/etc/pam.d/gdm
cp /etc/pam.d/gdm gdm.$secondes
echo "
@include scribe-account
@include scribe-session
@include scribe-auth" >> /etc/pam.d/gdm
#partages samba
mkdir /media/commun
mkdir /media/groupes
mkdir /media/professeurs
mkdir /media/perso
chmod 777 /media/commun
chmod 777 /media/groupes
chmod 777 /media/professeurs
chmod 777 /media/perso
cp /etc/security/pam_mount.conf.xml /etc/security/pam_mount.conf.xml.$secondes
commun=""
groupes=""
professeurs=""
perso=""
grep "/media/commun" /etc/security/pam_mount.conf.xml >/dev/null; if [ $? != 0 ];then sed -i "/<\\pmvarrun>/a\ $commun" /etc/security/pam_mount.conf.xml; else echo "commun deja present";fi
grep "/media/groupes" /etc/security/pam_mount.conf.xml >/dev/null; if [ $? != 0 ];then sed -i "/<\\pmvarrun>/a\ $groupes" /etc/security/pam_mount.conf.xml; else echo "groupes deja present" ;fi
grep "/media/professeurs" /etc/security/pam_mount.conf.xml >/dev/null; if [ $? != 0 ];then sed -i "/<\\pmvarrun>/a\ $professeurs" /etc/security/pam_mount.conf.xml; else echo "professeurs deja present" ;fi
grep "/media/perso" /etc/security/pam_mount.conf.xml >/dev/null; if [ $? != 0 ];then sed -i "/<\\pmvarrun>/a\ $perso" /etc/security/pam_mount.conf.xml; else echo "perso deja present";fi
#/etc/profile
cp /etc/profile profile.$secondes
echo "
export LC_ALL=fr_FR.utf8
export LANG=fr_FR.utf8
export LANGUAGE=fr_FR.utf8
" >> /etc/profile
#/etc/security/group.conf
grep "*;*;*;Al0000-2400;floppy,audio,cdrom,video,plugdev,scanner" /etc/security/group.conf >/dev/null; if [ $? != 0 ];then echo "*;*;*;Al0000-2400;floppy,audio,cdrom,video,plugdev,scanner" >> /etc/security/group.conf; else echo "group.conf ok";fi
#supression de l'applet fast-user-switch-applet
gconftool --direct --config-source xml:readwrite:/etc/gconf/gconf.xml.mandatory --type bool --set '/desktop/gnome/lockdown/disable_user_switching' true
gconftool --direct --config-source xml:readwrite:/etc/gconf/gconf.xml.mandatory --type list --list-type=string --set '/apps/panel/default_setup/general/applet_id_list' '[mixer,clock,notification_area,show_desktop_button,window_list,workspace_switcher,trashapplet]'
apt-get --yes --purge remove fast-user-switch-applet
echo "reboot necessaire"