#!/bin/bash # postinst script for se3-ocs-clientwin # # see: dh_installdeb(1) set -e # summary of how this script can be called: # * `configure' # * `abort-upgrade' # * `abort-remove' `in-favour' # # * `abort-remove' # * `abort-deconfigure' `in-favour' # `removing' # # for details, see http://www.debian.org/doc/debian-policy/ or # the debian-policy package case "$1" in install|configure) . /usr/share/se3/includes/config.inc.sh -svm > /dev/null if [ "X$xppass" = "X" ]; then # if empty echo "pas de mot de pass defini pour adminse3" exit 1 fi if [ -e /var/se3/Progs/install/ocs-config.bat ]; then echo "Suppression de ocs-config.bat devenu inutile." rm -rf /var/se3/Progs/install/ocs-config.bat fi ##### SUPPRESSION de ocs-config.bat. Gereration du job CPAU cote serveur. ### OcsDir="/var/se3/Progs/ro/inventory/deploy" # Fix for wine when running from sudo export HOME=/root JOB=cpauOcs.job WINECMD="env WINEDEBUG=-all wine" rm -f $OcsDir/$JOB echo "Creation du $JOB CPAU destine a installer ocs-clientwin sur les postes." TASK="echo Veuillez patienter...&&c:\\tmpOcs\\OcsAgentSetup.exe /S /server:$se3ip /pnum:909 /np /debug" echo "TASK se3 : $TASK" | sed -e "s/$xppass/XXXXXX/g" cd /tmp $WINECMD /home/netlogon/CPAU.exe -u adminse3 -wait -p $xppass -file $JOB -lwop -c -ex "$TASK" -enc > /dev/null mv $JOB $OcsDir ### CREATION DE ocs.bat cote serveur pour les postes Clients W98 ou WinXP ### echo "Creation de $OcsDir/ocs.bat" OcsDirWin="\\\\$netbios_name\\Progs\\ro\\inventory\\deploy" echo ":: Installation du service OCS sur les postes clients">$OcsDir/ocs.bat echo "@echo OFF">>$OcsDir/ocs.bat # Test si OCS est deja installe>$OcsDir/ocs.bat echo "If \"%ProgramFiles%\" == \"\" Set ProgramFiles=C:\Program Files">>$OcsDir/ocs.bat echo "If Exist \"%ProgramFiles(x86)%\" Set ProgramFiles=%ProgramFiles(x86)%">>$OcsDir/ocs.bat echo "If Exist \"%ProgramFiles%\OCS Inventory Agent\OCSInventory.exe\" Goto FIN">>$OcsDir/ocs.bat echo "Set TMPOCS=c:\\tmpOcs">>$OcsDir/ocs.bat echo "Set CPAU=\\\\$netbios_name\\netlogon\\CPAU.exe">>$OcsDir/ocs.bat echo "If Not Exist %TMPOCS% mkdir %TMPOCS%">>$OcsDir/ocs.bat echo "if \"%OS%\" == \"Windows_NT\" goto InstWnt">>$OcsDir/ocs.bat echo "" >>$OcsDir/ocs.bat echo ":InstW9x">>$OcsDir/ocs.bat echo ":: Pour les Win98, execution de OcsAgentSetup.exe directement a partir du serveur">>$OcsDir/ocs.bat echo "echo Installation OCS-NG pour Win9x">>$OcsDir/ocs.bat echo "\"$OcsDirWin\\OcsAgentSetup.exe\" /S /server:$se3ip /pnum:909 /np /debug">>$OcsDir/ocs.bat echo "Goto InstOk">>$OcsDir/ocs.bat echo "">>$OcsDir/ocs.bat echo ":InstWnt">>$OcsDir/ocs.bat echo "echo Installation OCS-NG pour WinXP">>$OcsDir/ocs.bat echo "xcopy /I /H /R /Y /Z /Q \"$OcsDirWin\\*\" %TMPOCS% >NUL">>$OcsDir/ocs.bat echo "If Not Exist \"%TMPOCS%\\$JOB\" Goto Err2">>$OcsDir/ocs.bat echo "\"%CPAU%\" -dec -file \"%TMPOCS%\\$JOB\" -nowarn -lwp -wait -outprocexit 2>NUL >NUL">>$OcsDir/ocs.bat echo "If ErrorLevel 1 Goto Err3">>$OcsDir/ocs.bat #echo "rmdir /S /Q \"%TMPOCS%\"">>$OcsDir/ocs.bat echo "Goto InstOk">>$OcsDir/ocs.bat echo "">>$OcsDir/ocs.bat echo ":Err2">>$OcsDir/ocs.bat echo "Echo Le fichier \"%TMPOCS%\\$JOB\" n'existe pas !">>$OcsDir/ocs.bat echo "">>$OcsDir/ocs.bat echo ":Err3">>$OcsDir/ocs.bat echo "rmdir /S /Q \"%TMPOCS%\"">>$OcsDir/ocs.bat echo "echo Erreur lors de l'installation d'OCS">>$OcsDir/ocs.bat echo "goto FIN">>$OcsDir/ocs.bat echo "">>$OcsDir/ocs.bat echo ":InstOk">>$OcsDir/ocs.bat echo "Echo Installation OCS : OK.">>$OcsDir/ocs.bat echo "">>$OcsDir/ocs.bat #echo ":FIN">>$OcsDir/ocs.bat ## AJOUT : REMONTEE IMMEDIATE DE L'INVENTAIRE (Olikin) ### JOB=cpauOcsRemontee.job rm -f $OcsDir/$JOB echo "Creation du $JOB CPAU destine a remonter immediatement l'inventaire sur le serveur $netbios_name." TASK="call $OcsDirWin\\ocsremontee.bat" echo "TASK se3 : $TASK" | sed -e "s/$xppass/XXXXXX/g" cd /tmp $WINECMD /home/netlogon/CPAU.exe -u adminse3 -wait -p $xppass -file $JOB -lwop -c -ex "$TASK" -enc > /dev/null mv $JOB $OcsDir echo "Creation du script $OcsDir/ocs.bat (remontee immediate d'inventaire)." echo "">>$OcsDir/ocs.bat echo "echo Remontee immediate de l'inventaire OCS sur le SE3.">>$OcsDir/ocs.bat echo "If Not Exist \"%TMPOCS%\\$JOB\" Goto Err4">>$OcsDir/ocs.bat echo "\"%CPAU%\" -dec -file \"%TMPOCS%\\$JOB\" -nowarn -lwp -wait -outprocexit 2>NUL >NUL">>$OcsDir/ocs.bat echo "If ErrorLevel 1 Goto Err5">>$OcsDir/ocs.bat echo "rmdir /S /Q \"%TMPOCS%\"">>$OcsDir/ocs.bat echo "Goto RemOk">>$OcsDir/ocs.bat echo "">>$OcsDir/ocs.bat echo ":Err4">>$OcsDir/ocs.bat echo "Echo Le fichier \"%TMPOCS%\\$JOB\" n'existe pas ! Pas de remontee immediate de l'inventaire !">>$OcsDir/ocs.bat echo "">>$OcsDir/ocs.bat echo ":Err5">>$OcsDir/ocs.bat echo "rmdir /S /Q \"%TMPOCS%\"">>$OcsDir/ocs.bat echo "echo Erreur lors de la remontee du rapport OCS.">>$OcsDir/ocs.bat echo "goto FINRem">>$OcsDir/ocs.bat echo "">>$OcsDir/ocs.bat echo ":RemOk">>$OcsDir/ocs.bat echo "Echo Remontee du premier inventaire OCS : OK.">>$OcsDir/ocs.bat echo "">>$OcsDir/ocs.bat echo ":FIN">>$OcsDir/ocs.bat echo "@echo OFF">$OcsDir/ocsremontee.bat echo "echo Remontee immediate de l'inventaire.">>$OcsDir/ocsremontee.bat echo "set OCSINI=%ProgramFiles%\\OCS Inventory Agent\\service.ini">>$OcsDir/ocsremontee.bat echo "echo Arret du service OCS...">>$OcsDir/ocsremontee.bat echo "net stop \"OCS INVENTORY SERVICE\" >NUL">>$OcsDir/ocsremontee.bat echo "Copy \"%OCSINI%\" %systemdrive%\\FILEOCSINI.TMP >NUL">>$OcsDir/ocsremontee.bat echo "echo Modification du parametre TTO_WAIT pour remontee de l'inventaire dans 2 sec.">>$OcsDir/ocsremontee.bat echo "type %systemdrive%\\FILEOCSINI.TMP | Findstr /V /I \"\\ \"%OCSINI%\"">>$OcsDir/ocsremontee.bat echo "Del %systemdrive%\\FILEOCSINI.TMP >NUL">>$OcsDir/ocsremontee.bat echo "echo TTO_WAIT=2 >> \"%OCSINI%\"">>$OcsDir/ocsremontee.bat echo "echo Redemarrage du service OCS...">>$OcsDir/ocsremontee.bat echo "net start \"OCS INVENTORY SERVICE\" >NUL">>$OcsDir/ocsremontee.bat #### AJOUT DE LA LIGNE DANS base/logon.bat ##### if [ "$(cat /home/templates/base/logon.bat | grep "ocs.bat")" = "" ]; then echo "Ajout de la ligne necessaire dans /home/templates/base/logon.bat" echo -e "\r">>/home/templates/base/logon.bat DEBVERS=$(cat /etc/debian_version) if [ "$DEBVERS" == "4.0" ]; then echo -e "::call \\\\\\\\$netbios_name\\Progs\\\\ro\\inventory\\deploy\\ocs.bat\r">>/home/templates/base/logon.bat else echo -e "call \\\\\\\\$netbios_name\\Progs\\\\ro\\inventory\\deploy\\ocs.bat\r">>/home/templates/base/logon.bat fi else echo "Template base deja correctement configure pour se3-ocs-clientwin." fi #### DROITS SUR Progs #### echo "Positionnement correct des droits sur le dossier de deploiement." chown -R admin:admins /var/se3/Progs/ro/inventory setfacl -R -m m:rwx /var/se3/Progs/ro/inventory [ -e /home/admin/Bureau/conf-ocs.bat ] && rm -f /home/admin/Bureau/conf-ocs.bat # on vire le vieux script de config (historique) pour eviter les erreurs... [ -e /var/se3/Progs/install/ocs-config.bat ] && rm -f /var/se3/Progs/install/ocs-config.bat echo "Configuration de se3-ocs-clientwin terminee." ;; abort-upgrade|abort-remove|abort-deconfigure) ;; *) echo "postinst called with unknown argument \`$1'" >&2 exit 1 ;; esac # dh_installdeb will replace this with shell code automatically # generated by other debhelper scripts. #DEBHELPER# exit 0