# ************************************************************************** # Copyright (C) 2005 Francois Audirac # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License. # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. # *************************************************************************** # File : extrait-profil # Author : Francois AUDIRAC # mailto:francois.audirac@gmail.com # http://www.webaf.net # Date : 03/12/2005 # Licence : GNU/GPL Version 2 # # Description: # ------------ # # @version $Id: extrait-profil,v 1.0 2005/12/03 22:00:00 # @author Francois Audirac # @project # @copyright Francois Audirac 03/12/2005 # # ************************************************************************* */ #!/bin/bash # extrait un profil d'un compte courant # attend un nom de dossier existant à la racine # et crée un tar.gz # teste si un dossier est passé en paramètre # On teste d'abord s'il y a un fichier à la suite passé en paramètres if [ -z $1 ]; then echo "Il manque un nom de profil à passer en paramètre" echo "comme par exemple : \"extrait-profil maternelle\" " exit 1; fi if [ -e $1 ]; then echo "Impossible d'extraire, le dossier \"$1\" existe déjà." echo "Il doit être supprimé, déplacé ou renommé sinon son contenu serait ecrasé." exit 1; fi # création du dossier profil /bin/mkdir -p $1 cp -r $HOME/GNUstep $1 cp -f $HOME/.wmrc $1 cp -f $HOME/.bash* $1 cp -f $HOME/.mtools* $1 rm -f $1/.bash_history mkdir -p $1/Docs mkdir -p $1/public_html chmod 700 $1/Docs chmod 755 $1/public_html # nettoyage éventuel rm -f $1/GNUstep/Defaults/*.bak rm -f $1/GNUstep/Defaults/*~ rm -f $1/GNUstep/.Appinfo/WindowMaker/* # vérification de liens en dur echo "************ Début de vérification du profil ******************* " /usr/bin/rgrep -r ${USER} $1/* echo "******************** Fin de Vérification *********************** " echo "Si aucune erreur n'apparait, c'est que votre profil est bon." echo "Appuyer sur Entrée pour continuer ou sur Ctrl+C pour interrompre l'opération." read # echo "Compression en $1.tar.gz" tar -cvzf ${1}.tar.gz ${1} # echo "L'extraction du profil est terminée" # rm -rf ${1} cp $1.tar.gz $HOME/public_html echo "Le profil *$1* est compressé et copié dans le dossier public_html" echo "Votre administrateur abuladmin est le seul à pouvoir l'installer, contactez-le." echo "Voulez-vous effacer le dossier *$1* contenant votre profil ? [o/N]" read REPONSE_EFFACE if [ "$REPONSE_EFFACE" = "o" ]; then rm -rf ${1}; echo "Le dossier $1 a été effacé !"; fi