home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Dream 52
/
Amiga_Dream_52.iso
/
Applix
/
install.cd
/
pkg
/
install.sh
< prev
Wrap
Linux/UNIX/POSIX Shell Script
|
1998-05-09
|
11KB
|
469 lines
#!/bin/bash
#
#install.sh (shell d'installation)
#---------------------------------------------------------------
#
TMP="/var/lib/applix-setup"
tmp="$TMP"
DIALOG="$CHEMIN/bin/dialog"
export DIALOGRC="$CHEMIN/bin/.dialogrc"
umask 022
if [ ! -f $tmp/ROOT_DIR ]; then
BACKTITLE="Installation APPLIXware 4.3.7 Office - $LANGUE (DEMO - Expire le 31/08/98)"
else
BACKTITLE="Installation APPLIXware 4.3.7 Office - $LANGUE (DEMO - Expire le 31/08/98)"
fi
file_pkg="$FILE_PKG"
TempFile="$tmp/apx_inst.$$"
# Shell interface to "dialog"
# Bruce Perens, November 1995
# This is free software under the GNU General Public License.
# Global options
# The variable $BACKTITLE specifies the back title.
# The variable $DIALOG_OPTIONS, initialized here to --clear, provides
# options you want on the command line of each dialog invocation.
# The variable $DIALOG_TEST can be set to "echo" to see the calls
# to dialog without executing them.
DIALOG_OPTIONS=""
# Make any dialogue box, with default settings and backtitle from
# $BACKTITLE in the environment.
#
# dialog --type arg arg ...
#---------------------------------------------------------------
#
dialogBox () {
local type="$1"
shift
local title=""
local backtitle=""
local text="$1"
shift
if [ $# -ge 1 ]; then
title="$1"
shift
fi
if [ -n "$BACKTITLE" ]; then
backtitle="$BACKTITLE"
fi
#$DIALOG_TEST
$DIALOG $DIALOG_OPTIONS --title "$title" --backtitle \
"$backtitle" "$type" "$text" 0 0 "$@" 2>&1 1>/dev/tty
local result=$?
Selection="$result"
return $result
}
# Display a file.
#
# fileBox filename [title]
#---------------------------------------------------------------
#
fileBox () {
dialogBox --textbox "$1" "$2"
}
#
# textBox [title]
#---------------------------------------------------------------
#
textBox () {
dialogBox --textbox $TempFile "$1"
local result=$?
rm -f $TempFile
return $result
}
#
# message box
#---------------------------------------------------------------
#
msgBox () {
dialogBox --msgbox "$1" "$2"
}
#
# info box
#---------------------------------------------------------------
#
infoBox () {
dialogBox --infobox "$1" "$2"
}
#
# yes ou no box
#---------------------------------------------------------------
#
yesNoBox () {
dialogBox --yesno "$1" "$2"
}
#
# input box
#---------------------------------------------------------------
#
inputBox () {
dialogBox --inputbox "$1" "$2" "$3"
}
#
# menu text title tag1 item1 ...
#---------------------------------------------------------------
#
menu () {
local text="$1"
shift
local title="$1"
shift
dialogBox --menu "$text" "$title" 0 "$@"
}
#
# checklist
# menu text title tag1 item1 status1 ...
#---------------------------------------------------------------
#
checklist () {
local text="$1"
shift
local title="$1"
shift
dialogBox --checklist "$text" "$title" $hauteur_check "$@"
if [ $Selection = "1" -o $Selection = "255" ]; then
Selection="Cancel"
echo $Selection >> $tmp/selection
fi
}
#
# radio list
# menu text title tag1 item1 status1 ...
#---------------------------------------------------------------
#
radiolist () {
local text="$1"
shift
local title="$1"
shift
dialogBox --radiolist "$text" "$title" 0 "$@"
}
#
# installation des packages sΘlectionΘs
#---------------------------------------------------------------
#
install_pkg() {
if [ ! -f $tmp/ROOT_DIR ]; then
echo "$DEST_DIR" > $tmp/ROOT_DIR
fi
if [ ! -d $DEST_DIR/applix/log/packages ]; then # test rep packages joel
mkdir -p $DEST_DIR/applix/log/packages
fi
if [ ! -d $DES_DIR/applix/log/scripts ]; then # test rep scripts joel
mkdir -p $DEST_DIR/applix/log/scripts
fi
local file=$1
SOURCE="`pwd`"
desc="`grep "D:$file:" $file_pkg | sed -n "s/^.*:.*://p"`"
infoBox "$desc" "Installation de $file"
if [ ! -d $DEST_DIR ]; then
mkdir -p $DEST_DIR 2> /dev/null
fi
(cd $DEST_DIR
# tar zxf $SOURCE/$file.tgz 2> /dev/null ;
echo "NOM DU PACKAGE: $file" > $DEST_DIR/applix/log/packages/$file
f="$SOURCE/$file"; taille_fichier $f;
echo "TAILLE DECOMPRESSEE: $taille Ko" >> $DEST_DIR/applix/log/packages/$file
echo "PACKAGE DESCRIPTION:" >> $DEST_DIR/applix/log/packages/$file
DESCRIPT="`grep "A:$file:" $SOURCE/$file_pkg`" #>> $DEST_DIR/applix/log/packages/$file
if [ -z "$DESCRIPT" ]; then
DESCRIPT="`grep "AON:$file:" $SOURCE/$file_pkg`" #>> $DEST_DIR/applix/log/packages/$file
fi
echo $DESCRIPT >> $DEST_DIR/applix/log/packages/$file
echo "`grep "D:$file:" $SOURCE/$file_pkg`" >> $DEST_DIR/applix/log/packages/$file
echo "FILE LIST:" >> $DEST_DIR/applix/log/packages/$file
( tar -xzlpvf - ) < $SOURCE/$file.tgz >> $DEST_DIR/applix/log/packages/$file 2> /dev/null ; #joel
if [ -r install/doinst.sh ] ; then
bash install/doinst.sh $DEST_DIR
rm -f install/doinst.sh
rm -rf install
fi)
}
#
# taille dΘcompressΘe du fichier α installer
##---------------------------------------------------------------
taille_fichier() {
taille=`gzip -l $f.tgz | sed -n '$ p' | cut -b10-19` #joel
taille=`expr $taille / 1024`
}
#
#
# recherche des packages
recherche () {
infoBox "Patientez pendant que je recherche la liste des applications de la\nversion $LANGUE dans le rΘpertoire $CHEMIN." "Patientez!"
sleep 1
file_lst=`cat file.lst`
}
#
# menu de sΘlection des packages α installer
#---------------------------------------------------------------
#
main_menu () {
# titre de la procΘdure d'installation
title=`grep "T:TITRE:" $file_pkg | sed -n "s/^.*:.*://p"`
#creation de la checkliste
chk_file="$tmp/chk.lst.$$"
cat << END > $chk_file
checklist \\
"Choisissez les applications avec les flΦches.
Validez avec la barre d'espacement. Ne pas
suprimer les fichiers prΘsΘlectionnez.
Installation dans $DEST_DIR""$APPLIX." "$title" \\
END
for file in $file_lst
do
# recherche des packages prΘsΘlectionΘs
auto_inst=`grep "A:$file:" $file_pkg | cut -c1-2`
if [ "$auto_inst" = "A:" ]; then
desc=`grep "A:$file:" $file_pkg | sed -n "s/^.*:.*://p"`
if [ ! -f $DEST_DIR/applix/log/packages/$file ]; then
echo " $file \"$desc\" \"off\" \\" >> $chk_file
fi
else
desc=`grep "AON:$file:" $file_pkg | sed -n "s/^.*:.*://p"`
echo " $file \"$desc\" \"on\" \\" >> $chk_file
fi
done
echo " " >> $chk_file
file_lst=`. $chk_file`
rm -r $chk_file
}
#
# dΘtermination de la taille totale des fichiers α installer
# et de la place disponible sur le disque dur de destination
#---------------------------------------------------------------
#
taille_totale () {
total_taille_fichier=0
for file in $file_lst
do
f=`echo $file | sed -n "s/\"//gp"`
taille_fichier $f
total_taille_fichier=`expr $taille + $total_taille_fichier`
done
if [ ! -d $DEST_DIR ]; then
mkdir -p $DEST_DIR 2> /dev/null
fi
devices=`df $DEST_DIR | grep "/dev" | cut -c1-11`
disque_free=`df $DEST_DIR | grep "/dev" | cut -c38-46`
disque_free=`expr $disque_free`
if [ ! $DEST_DIR = "/" ]; then
rmdir -p $DEST_DIR 2> /dev/null
fi
taille_reste=`expr $disque_free - $total_taille_fichier`
cat <<EOF>> $TempFile
Place disponible sur le disque $devices: $disque_free Ko
Taille totale des fichiers α installer : $total_taille_fichier Ko
EOF
if [ "$taille_reste" -le "0" ]; then
temp2="INSTALLATION IMPOSSIBLE!!!"
cat <<EOF>> $TempFile
Installation impossible! La place disponible sur le disque dur
est insuffisante. Choisir un autre disque dur ou suprimer des
packages.
L'espace disque pour cette installation doit Ωtre de $total_taille_fichier Ko.
EOF
temp1=`cat $TempFile`
msgBox "$temp1" "$temp2"
rm -f $TempFile
rm -f $tmp_file
else
temp2="DEBUTER L'INSTALLATION"
cat <<EOF>> $TempFile
Taille restante sur le disque $devices: $taille_reste Ko
La place disponible sur votre disque dur vous permet de lancer
la procΘdure d'installation d'APPLIXware. Confirmez par Oui
(Installation) ou Non (Annuler l'installation).
EOF
temp1=`cat $TempFile`
yesNoBox "$temp1" "$temp2"
rm -f $TempFile
rm -f $tmp_file
# $disque_free = place disponible sur le disque d'installation
# $total_taille_fichier = taille totale des fichiers α installer
if [ "$Selection" = "0" ]; then
installation
fi
fi
}
#
# passage des fichier a installer a la fonction install_pkg
#---------------------------------------------------------------
#
installation () {
for file in $file_lst
do
f=`echo $file | sed -n "s/\"//gp"`
install_pkg $f
done
rm -f $tmp_file
}
#
# recherche les packages prΘinstallΘs
#---------------------------------------------------------------
#
pre_install () {
file_lst=`cat file.lst`
ligne_tempo=
for file in $file_lst
do
auto_inst=`grep "AON:$file:" $FILE_PKG | cut -c1-4`
if [ "$auto_inst" = "AON:" ]; then
ligne_tempo="$ligne_tempo; $file" # ligne temporaire
longueur_ligne=`expr "$ligne_tempo" : ".*"` # longueur de la ligne
if [ $longueur_ligne -le 50 ]; then # tant que ligne a moins de 50c
ligne="$ligne $file" # ajout fichier dans la ligne
else
echo $ligne >> $tmp/file.txt # sauve la ligne
ligne="$file" # Initialise les variable
ligne_tempo="$file"
longueur_ligne= #
fi
fi
done
echo $ligne >> $tmp/file.txt # sauve derniere ligne si inferieure a 50 c
# prΘparation du fichier $TempFile
cat << EOF >> $TempFile
Installation de la version $LANGUE
---------------------------------------------------------
Les packages suivants ont ΘtΘ sΘlectionnΘs pour vous:
EOF
cat $tmp/file.txt >> $TempFile
rm -f $tmp/file.txt
cat << EOF >> $TempFile
Vous ne devez en aucun cas les dΘsΘlectionner sous peine
de rendre instable la version $LANGUE. Vous pouvez
complΘter l'installation d'APPLIXware en sΘlectionnant
des packages suplΘmentaires."
EOF
}
#
# calcul du nombre de ligne dans le fichier $TempFile
#--------------------------------------------------------
#
nb_ligne () {
nombre_ligne=`wc -l $TempFile | cut -d/ -f1`
if [ "$nombre_ligne" -le "18" ]; then
hauteur="0"
largeur="0"
else
hauteur="18"
largeur="61"
fi
}
#
# DΘbut du shell
#---------------------------------------------------------------
#
if [ ! -f $tmp/ROOT_DIR ]; then
pre_install
textBox "IMPORTANT!!!"
fi
recherche
# Test si tous les packages sont installes
a=0
hauteur_check=0
for file in $file_lst
do
if [ ! -r $DEST_DIR/applix/log/packages/$file ]; then
a=`expr $a + 1`
hauteur_check=`expr $a`
if [ "$hauteur_check" -ge "10" ]; then
hauteur_check=10
fi
fi
done
if [ $a = "0" ]; then
infoBox "\nTous les packages sont dΘjα installΘs.\n" "ATTENTION!"
sleep 3
exit
fi
main_menu
if [ -r $tmp/selection ]; then
Selection=`cat $tmp/selection`
rm -f $tmp/selection
fi
if [ ! $Selection = "Cancel" ]; then
taille_totale
fi
exit
#-----FIN-------------------------------------------------------