#!/bin/bash
# programme d'initialisation du pc après formatage de la partition racine
# ouvrir un shell en root puis taper initialisation
clear
# déclaration des variables
FILE=$HOME_CLIENT/initialisation
date_modif=$(stat -c %z -- "$FILE" )
MOZILLA_PLUGINS=/usr/lib/mozilla/plugins
HOME_CLIENT=/home/thierry
FILE_FIRMWARE=snape26.bin
FILE_VAR_JRE=/etc/profile.d/jre.sh
##################################################################################################################################"
function get_installarchiveopensi () {
printf "Installation de opensi"
if [ -f $HOME_CLIENT/archive/opensi-serveur* ]
then
if [ -d /var/lib/tomcat/webapps/ ]
then if [ -f /var/lib/tomcat/webapps/OpenSI/opensi.cfg ] # on preserve la conf et on supprime tout
then
cp /var/lib/tomcat/webapps/OpenSI/opensi.cfg /var/lib/tomcat/webapps/
rm -rf /var/lib/tomcat/webapps/OpenSI/
fi
cd /var/lib/tomcat/webapps/
tar xzf $HOME_CLIENT/archive/opensi-serveur*
if [ -f /var/lib/tomcat/webapps/opensi.cfg ]
then
mv /var/lib/tomcat/webapps/opensi.cfg /var/lib/tomcat/webapps/OpenSI/opensi.cfg
else
cd ./OpenSI > /dev/null
if [ -f opensi.unix.cfg ] then mv opensi.unix.cfg opensi.cfg
kwrite opensi.cfg > /dev/null
fi
printf 'réussi'
fi
fi
else # pas d'archive
firefox http://www.opensi.org/Telechargements.html
get_installarchiveopensi
fi
}
function get_installarchivetomcat() {
printf "Installation de Tomcat"
if [ -f $HOME_CLIENT/archive/apache-tomcat* ] # l'archive tomcat est presente
then
if [ -d /var/lib/tomcat ]
then
rm /var/lib/tomcat > /dev/null # on efface tout si existant.
fi
cd /var/lib/
tar -xzf $HOME_CLIENT/archive/apache-tomcat*
var=$(find /var/lib/ -name apache-tomcat*)
if [ -n $var ] # la variable n'est pas vide
then
ln -s ./apache-tomcat* ./tomcat
fi
else # il n'y a pas d'archive
firefox http://tomcat.apache.org/download-55.cgi;
get_installarchivetomcat;
fi
}
get_installopensi () {
get_installarchivetomcat
get_installarchiveopensi
}
#--------------------------------------------------------------------------------------------------------------
get_installphpmyadmin () {
printf 'voulez vous le RPM au lieu du site? (y/n/q): '
read yn
case $yn in
y | Y | o | O)
urpmi phpmyadmin
;;
n | N)
firefox http://www.phpmyadmin.net/home_page/
var=$(find $HOME_CLIENT -name phpMyAdmin*)> /dev/null; # httpd.conf sur apache2
set $var
if [ -d /var/www/html/ ]
then
cd /var/www/html/
else
mkdir /var/www/html/
cd /var/www/html/
fi
tar xzf $1
;;
q | Q)
continue
;;
*)
echo ""
echo "Please enter 'y', 'n', or 'q'."
get_installphpmyadmin
;;
esac
}
function get_installLAMP() {
var=$(rpm -qa |grep -i apache)> /dev/null;
set $var;
if [ -z "$1" ] # la chaine de caractère est vide
then urpmi apache
fi
var=$(find /etc/httpd/ -name httpd.conf)> /dev/null; # httpd.conf sur apache2
if [ -n "$var" ] # la variable n'est pas vide
then
if [ ! grep 'ServerName http://localhost/facturation' $var ]
then
echo 'ServerName *' >> $var
echo 'NameVirtualhost *' >> $var
echo '' >> $var echo '<VirtualHost *>' >> $var
echo 'ServerName /localhost/facturation' >> $var
echo 'DocumentRoot $HOME_CLIENT/' >> $var
echo '</VirtualHost>' >> $var echo '' >> $var echo '<VirtualHost *>' >> $var
echo 'ServerName /localhost/phpMyAdmin' >> $var
echo 'DocumentRoot /var/www/' >> $var
echo '</VirtualHost>' >> $var echo '' >> $var echo '<VirtualHost *>' >> $var
echo 'ServerName /localhost/opensi_passerelle' >> $var
echo 'DocumentRoot $HOME_CLIENT/' >> $var
echo '</VirtualHost>' >> $var echo '' >> $var
echo '<VirtualHost *>' >> $var
echo 'ServerName /localhost/table_matiere' >> $var
echo 'DocumentRoot $HOME_CLIENT/' >> $var
echo '</VirtualHost>' >> $var echo '' >> $var
fi
fi
var=$(rpm -qa |grep -i mysql)> /dev/null;
set $var;
if [ -z "$1" ] # la chaine de caractère est vide
then echo " mysql: choose a very fast "
urpmi mysql4
else printf " mysql installé";
fi
if [ \( \( -d /var/www/html/phpMyAdmin \) -o \( -d /var/www/phpMyAdmin \) \) ] then printf "phpMyAdmin installé";
else
get_installphpmyadmin
fi
/etc/init.d/httpd reload
service mysqld restart
} # function install-LAMP()
#--------------------------------------------------------------------------------------------------------------
get_installarchivejava () {
search=$(find /home/ -name jre*)> /dev/null; if [ -n "$search" ] # la variable n'est pas vide
then
set $search # il y a peut être plusieurs archives
sh $1 # crée un RPM et l'installe
rm jre* # nettoyage
fi
}
get_installjava () {
var=$(find /usr/java/ -name libjavaplugin_oji.so)> /dev/null;
set $var;
if [ -n "$1" ] # la variable n'est pas vide
then printf" java installé"
else firefox http://java.com/fr/download/linux_manual.jsp
get_installarchivejava
ln -fs $var /usr/lib/mozilla/plugins/
fi
}
get_installarchiveflash () {
search=$(find /home/ -name install_flash*)> /dev/null; if [ -n "$search" ] # la variable n'est pas vide
then
set $search # il y a peut être plusieurs archives
if [ "${1##*.}"="gz" ]
then
cd ~/tmp
tar xzf $1
cd install_flash*
sh flash*
rm flash*
else
sh $1 fi
fi
}
get_installflash () {
printf 'voulez vous le RPM gplflash au lieu du site macromedia? (y/n): '
read yn
case $yn in
y | Y | o | O)
urpmi gplflash
;;
n | N)
get_installarchiveflash # on cherche d'abord une archive à installer
if [ -f /usr/lib/mozilla/plugins/flash* ] # elle est installée
then printf 'flash installé'
else # elle n'existe pas
firefox http://www.adobe.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash&Lang=French
get_installarchiveflash
fi
;;
*)
echo ""
echo "Please enter 'y', 'n'."
get_installflash
;;
esac
}
get_installplugins () {
if [ ! -d /usr/lib/mozilla/plugins ]
then
mkdir /usr/lib/mozilla/plugins
fi
printf 'voulez vous (ré)installer les plugins de firefox? (y/n/q): '
read yn
case $yn in
y | Y | o | O)
#remise à blanc des liens firefox
if [ -d /usr/lib/mozilla/plugins ]
then
rm -rf $HOME_CLIENT/.mozilla/plugins > /dev/null
rm -rf /usr/lib/mozilla/plugins > /dev/null
fi
if [ -d /usr/java/ ]
then
rm -rf /usr/java/ > /dev/null
fi
get_installjava
get_installflash
;;
n | N)
if [ -f /usr/lib/mozilla/plugins/flash* ]
then printf " Flash installé "
else printf " Flash doit obligatoirement être installé"
get_installflash
fi
;;
q | Q)
continue
;;
*)
echo ""
echo "Please enter 'y', 'n', or 'q'."
get_installplugins
;;
esac
}
get_installfirefox () {
var=$(rpm -qa |grep -i firefox)> /dev/null;
set $var;
if [ -n "$1" ] # la chaine de caractère n'est pas vide
then echo "
firefox installé"
else if [ -d /usr/lib/mozilla* ]
then
rm -df /usr/lib/mozilla*
fi
urpmi mozilla-firefox-fr mozilla-firefox
# modification du repertoire.
var=$(find /usr/lib/mozilla-*)
set $var
if [ -n $1 ] # il y a une extension à mozilla
then
ln -s $1 /usr/lib/mozilla fi
fi
}
#------------------------------------------------------------------------------------------------------------------------------
printf " installation"
get_installfirefox
get_installplugins
printf " installation de LAMP "
get_installLAMP
printf " installation de OpenSI"
get_installopensi
echo "Fin des verifications preliminaires"
echo "-----------------------------------------------------------"
echo "création des liens symboliques"
if [ -d /etc/apache1/conf/ ] # si apache1 existe
then
ln -fs $HOME_CLIENT/opensi_passerelle /var/www/html
ln -fs $HOME_CLIENT/table_matiere /var/www/html
ln -fs $HOME_CLIENT/facturation /var/www/html
if [ -d /var/www/phpmyadmin/ ]
then ln -fs /var/www/phpmyadmin /var/www/html fi
fi
ln -fs $HOME_CLIENT/scripts/daily/* /etc/cron.daily
ln -fs $HOME_CLIENT/scripts/rsync_backup_compta /etc/cron.monthly/rsync_backup_compta
var=$(find /usr/java/ -name libjavaplugin_oji.so)> /dev/null; # recherche de la directory java
set $var; # eclatement de 2 lignes
if [ -n "$1" ]
then var=$1; #/usr/java/jre1.5.0_06/plugin/i386/ns7-gcc29/libjavaplugin_oji.so
fi
ln -fs $var $MOZILLA_PLUGINS # lien java
ln -fs $MOZILLA_PLUGINS $HOME_MOZILLA #lien mozilla avec le home
echo "liens symboliques installé"
echo "-----------------------------------------------------------"
echo "installation de programme annexe"
echo ""
echo " parametrage du scanner"
if [ ! -f /usr/bin/xsane ]; then; urpmi xsane; fi;
rm -f /etc/sane.d/*
echo snapscan > /etc/sane.d/dll.conf
echo '#------------------------------ General -----------------------------------' > /etc/sane.d/snapscan.conf
echo '' >> /etc/sane.d/snapscan.conf
echo '# Change to the fully qualified filename of your firmware file, if' >> /etc/sane.d/snapscan.conf
echo '# firmware upload is needed by the scanner' >> /etc/sane.d/snapscan.conf
echo 'firmware /usr/share/sane/firmware/snape26.bin' >> /etc/sane.d/snapscan.conf
echo '#--------------------------- USB scanners -----------------------------------' >> /etc/sane.d/snapscan.conf
echo '# These USB devices will be probed automatically' >> /etc/sane.d/snapscan.conf
echo '# (This will currently work only on Linux)' >> /etc/sane.d/snapscan.conf
echo '' >> /etc/sane.d/snapscan.conf
echo '# Agfa Snapscan e26' >> /etc/sane.d/snapscan.conf
echo 'usb 0x06bd 0x2097' >> /etc/sane.d/snapscan.conf
echo ""
echo "réalisé"
echo "-------------------------------------------------------------"
echo "configuration de /etc/hosts"
echo '127.0.0.1 tr.maison.fr tr localhost' > /etc/hosts
echo '192.168.1.11 rmc.maison.fr rmc ' >> /etc/hosts
echo '192.168.129.201 zaurus.maison.fr zaurus' >> /etc/hosts
echo '192.168.1.9 celine.maison.fr celine ' >> /etc/hosts
echo '80.82.17.133 ubuntu-fr.org www.ubuntu-fr.org forum.ubuntu-fr.org planet.ubuntu-fr.org doc.ubuntu-fr.org ' >> /etc/hosts
echo '80.82.17.133 kubuntu-fr.org www.kubuntu-fr.org forum.kubuntu-fr.org planet.kubuntu-fr.org doc.kubuntu-fr.org ' >> /etc/hosts
echo ""
echo "réalisé"
echo "-------------------------------------------------------------"
echo ""
echo "configuration de /etc/profile"
var=$(find /usr/java/ -name jre*)> /dev/null; # recherche de la directory java
if [ -n "$var" ] then
echo JAVA_HOME=$var >$FILE_VAR_JRE echo JRE_HOME=$var >>$FILE_VAR_JRE
var=$(find /var -name tomcat*)> /dev/null;# recherche de la directory tomcat
echo TOMCAT=$var >>$FILE_VAR_JRE
echo CATALINA_HOME=$var >>$FILE_VAR_JRE
echo >>$FILE_VAR_JRE
echo >>$FILE_VAR_JRE
echo ' PATH=$PATH:$JAVA_HOME/bin '>>$FILE_VAR_JRE
echo ' export JRE_HOME JAVA_HOME PATH TOMCAT CATALINA_HOME' >>$FILE_VAR_JRE
export JRE_HOME JAVA_HOME PATH TOMCAT CATALINA_HOME;
echo "réalisé";
else
echo "inchangé";
fi
echo ""
echo "-------------------------------------------------------------"
echo ""
echo "Test de tomcat"
/var/lib/tomcat/bin/startup.sh> /dev/null;
sleep 1
firefox http://localhost:8080/
sleep 1
/var/lib/tomcat/bin/shutdown.sh> /dev/null;
echo ""
echo "-------------------------------------------------------------"
echo ""
echo "lilo.conf:"
if [ -f /etc/lilo.conf ]
then
var=$(grep kubuntu /etc/lilo.conf)> /dev/null;
if [ -z $var ]
then
echo "configuration"
echo ""
echo 'other=/dev/hda3' >> /etc/lilo.conf
echo ' label="kubuntu"' >> /etc/lilo.conf
echo ' table=/dev/hda' >> /etc/lilo.conf
exec lilo
else echo "déja configuré"
fi
fi
if [ -d $HOME_CLIENT/scripts/ ]
then
echo "Verification des scripts de sauvegarde"
echo "Mise en place de crontab"
echo SHELL=/bin/bash > /etc/crontab
echo PATH=/sbin:/bin:/usr/sbin:/usr/bin >> /etc/crontab
echo MAILTO=root >> /etc/crontab
echo HOME=/ >> /etc/crontab
echo >> /etc/crontab
echo \# run-parts >> /etc/crontab
echo 01 \* \* \* \* root nice -n 19 run-parts /etc/cron.hourly >> /etc/crontab
echo 02 21 \* \* \* root nice -n 19 run-parts /etc/cron.daily >> /etc/crontab
echo 22 21 \* \* 0 root nice -n 19 run-parts /etc/cron.weekly >> /etc/crontab
echo 42 21 1 \* \* root nice -n 19 run-parts /etc/cron.monthly >> /etc/crontab
echo ""
echo " OK"
echo "-------------------------------------------------------------"
else
echo " La directory $HOME_CLIENT/scripts/ n'à pas été trouvée. "
echo " La mise en place des sauvegardes à échoué" fi
echo " Les plus "
if [ -f /usr/lib/libdvdcss* ]
then echo "lbdvdcss installé"
else urpmi libdvdcss xine-win32
fi
echo " FIN DES PARAMETRAGES: REDEMARRER LE PC"
|