-
Notifications
You must be signed in to change notification settings - Fork 0
/
elan.sh
executable file
·136 lines (134 loc) · 3.99 KB
/
elan.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
# Elan Gestionaire de paquet.
# Realise par Mathieu Rheaume <ddrmanxbxfr@gmail.com>
# Location : Quebec, Quebec, Canada
# Mai 2011
#!/bin/bash
# Va chercher le repertoire ou elan est installe grace au script.
# Allez le modifier au besoin.
DIR=`sh /etc/elan/directory.sh`
case $1 in
#Fonction pour faire afficher la description.
"description")
$DIR/formules/$2.sh desc
if ((`echo $?` != "0"))
then
clear
echo "============================================================================"
echo "*ATTENTION*Il y a eu un probleme lors de la lecture des formules.*ATTENTION*"
echo "Soit que le fichier n'existe pas ou qu'il y a une erreure de permission."
echo "Vous pouvez reparer les permissions avec la commande \"elan fix-perms\""
echo "============================================================================"
fi
;;
#Fonction pour installer le packet.
"install")
#Verifie si le paquet existe sinon affiche un message.
ls $DIR/formules/$2.sh 1>/dev/null 2>/dev/null
if [ "`echo $?`" = 0 ]
then
#Recherche si le packet est dans la base de donnees des installes
#Variable RECHERCHE pour verifier si le fichier existe et la version a l'interieur de la db.
RECHERCHE=`cat $DIR/logiciels_db | grep "$2" | awk '{print $1}'`
if [ "$RECHERCHE" != "" ]
then
echo "Le paquet $2 est deja present sur le systeme."
RECHERCHE=`cat $DIR/logiciels_db | grep "$2" | awk '{print $2}'`
if [ "$RECHERCHE" = "`$DIR/formules/$2.sh var_update`" ]
then
echo "Le paquet $2 est a jour!"
else
echo "Mise a jour du paquet $2"
$DIR/formules/$2 uninstall
$DIR/formules/$2 install
fi
else
#Cree un dossier reserve au depacktage du packet.
echo "Installation de $2"
$DIR/formules/$2.sh install
echo "Installation reussi!"
fi
else
echo "Le paquet $2 n'existe pas!"
#Verification si la recherche trouvera un quelque chose
ls $DIR/formules/$2* 1>/dev/null 2>/dev/null
if [ "`echo $?`" = 0 ]
then
echo "Vous pourriez installer :"
#Affichage d'une recherche avec le nom du paquet
for i in $( ls $DIR/formules/$2* ); do
echo ""
sh $i desc
done
fi
fi
;;
#Fonction pour desinstaller le packet.
"uninstall")
RECHERCHE_DEL=`cat $DIR/logiciels_db | grep "$2" | awk '{print $1}'`
if [ "$RECHERCHE_DEL" = "$2" ]
then
echo "Debut de la deinstallation de $2."
$DIR/formules/$2.sh uninstall
echo "Deinstallation termine"
else
echo "Le paquet n'est pas present sur le systeme"
ls $DIR/formules/$2* 1>/dev/null 2>/dev/null
if [ "`echo $?`" = 0 ]
then
echo "Vous pourriez deinstaller :"
#Affichage d'une recherche avec le nom du paquet
for i in $( ls $DIR/formules/$2* )
do
echo ""
sh $i desc
done
fi
fi
;;
"search")
#Test si il trouve des paquets avant de rentrer dans la boucle
ls $DIR/formules/$2* 1>/dev/null 2>/dev/null
if [ "`echo $?`" = 0 ]
then
echo ""
echo "Les resultat de la recherche sont"
for i in $( ls $DIR/formules/$2* ); do
echo ""
sh $i desc
done
echo ""
else
#Verification si la recherche trouvera un quelque chose
echo "Aucun paquet trouve"
fi
;;
#Liste les paquets installe.
"packages-installed")
echo "Les paquets present sur le systeme sont"
cat $DIR/logiciels_db | awk '{print $1}'
;;
#Liste les dependances du paquet.
#Le paquet dois le supporter.
"list-dep")
grep "list-dep" $DIR/formules/$2.sh 1>/dev/null 2>/dev/null
if [ "`echo $?`" = 0 ]
then
sh $DIR/formules/$2.sh list-dep
else
echo "Le paquet que vous tentez d'obtenir les dependances ne supporte pas le mode list-dep de elan ou n'existe pas."
fi
;;
#Fonction qui permet de reparer les permissions des formules.
"fix-perms")
echo "Reparation des permissions des formules en cours."
chmod u+x * $DIR/formules/*.sh
echo "Les permissions ont ete repare avec succes"
;;
#Affichage du menu pour l'utilisation.
*)
echo "Utilisation de elan."
echo "============================"
echo "elan [option] nom_du_package"
echo "Options possible : packages-installed, uninstall, install, description, search, fix-perms"
;;
esac