-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathprojet.sh
120 lines (109 loc) · 2.37 KB
/
projet.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
#!/bin/bash
function menu(){
while true
do
echo "+++++++++++++++ Bienvenue ($USER) +++++++++++++++++++"
echo "1) : Lancer la commande lshw"
echo "2) : Lancer la commande lsusb"
echo "3) : HELP"
echo "4) : Afficher menu graphique"
echo "5) : Afficher menu textuel"
echo "6) : Sauvgarder les informations pertinentes"
echo "7) : Version et auteurs"
echo "8) : Afficher les informations pertinentes"
echo "9) : Afficher les lignes contenant le MOT CLE"
echo "0) : Quitter"
echo "+++++++++++++++++++++++++++++++++++++++++++++++++++++"
echo "Votre choix : "
read INPUT_STRING
case $INPUT_STRING in
1) sudo lshw;;
2) lsusb;;
3) help;;
4) ./menu_graphique.sh;;
5) menu;;
6) save_info;;
7) auteur_version;;
8) file="${OPTARG}" ;Affichage_InfoPertinantes;;
9) Affichage_MotClexd;;
0) exit;;
*) echo "Choix incorrecte";;
esac
done
}
function save_info(){
echo `sudo lshw > save.txt`
echo `lsusb >> save.txt`
sudo cp save.txt /usr/bin/projet/$s
}
function Affichage_InfoPertinantes
{
if [ -e /usr/bin/projet/"${file}" ]
then {
if [ -f /usr/bin/projet/"${file}" ]
then
cat /usr/bin/projet/"${file}"
else
echo "L'argument passé en parametre n'est pas un fichier"
fi
}
fi
fichierMot_Cle=${file}
}
function auteur_version(){
echo "Version 1.0.0 - Authors: Wassim ben romdhane & Bacim oueslati"
}
function Affichage_MotClexd
{
cat | grep -i $Mot_Cle /usr/bin/projet/"$fichierMot_Cle"
}
function help(){
cat /etc/help.txt
}
if [ "$1" == "" ]
then
echo "no argument"
exit
fi
if [ "$1" == "-help" ]
then
help
exit
fi
while getopts ":hxls:vm:f:go:" option
do
case $option in
h)
help
;;
x)
sudo lshw
;;
l)
lsusb
;;
s)
d=$(date +%Y-%m-%d)
s="$OPTARG"_$d
save_info $s_$d
echo "Les informations sont enregistrées dans le fichier /usr/bin/projet/$s"
;;
g)
./menu_graphique.sh
;;
v)
auteur_version
;;
m)
menu
;;
o)
file="${OPTARG}" ;Affichage_InfoPertinantes
;;
f)
Mot_Cle="${OPTARG}"; Affichage_MotClexd
;;
?)
echo "L'option $OPTARG est invalide"
esac
done