#!/bin/bash

# ------------------------------------------------------
# This program will manage users on your system.
# Copyright (C) 2005 Jean-Louis Louere <jl_chez_machinchose.com>
# 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., 
# 675 Mass Ave, Cambridge, MA 02139, USA.
# ---------------------------------------



LOG="/tmp/intranet.log"                  ; export LOG

if [ -z $DISPLAY ]
   then
      DIALOG=dialog
   else
      DIALOG=Xdialog
fi

fichtemp=`tempfile 2>/dev/null` || fichtemp=/tmp/test$$
trap "rm -f $fichtemp" 0 1 2 5 15


# choisir un mot de passe mysql root :
$DIALOG --backtitle "Choisissez un mot de passe" \
--title " Intranet" \
 --inputbox "Choisissez le mot de passe \n de l'utilisateur root de MySql \n noter le, vous allez en avoir besoin :" 16 51 2> $fichtemp
valret=$?
cat $fichtemp

mysqladmin -u root password `$fichtemp`

echo " Ne pas oublier ce mot de passe"
cat $fichtemp
echo "qui va être écrit dans un fichier sur le bureau de l'admin"

#mise en pause du script jusqu'a intervention de l'admin
echo "Appuyer la touche <Entrée> pour continuer..."
read touche
case $touche in
*)	echo "Reprise du script..."
	;;
esac

# creation du fichier password
	echo `cat $fichtemp` > /home/jpg/Desktop/password_mysql
