-
Notifications
You must be signed in to change notification settings - Fork 0
/
eos_gather_infos.sh
60 lines (51 loc) · 1.48 KB
/
eos_gather_infos.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
#!/bin/bash
#
#
VERSION="0.01"
DATE=`date +"%Y%m%d%H%M%S"`
LOG_FILE="$PWD/eleos-$DATE.log"
# Functions
#-----------------------------------------------------------------------------
displaymessage() {
echo "$*"
}
displaytitle() {
displaymessage "------------------------------------------------------------------------------"
displaymessage "$*"
displaymessage "------------------------------------------------------------------------------"
}
displayerror() {
displaymessage "$*" >&2
}
# First parameter: ERROR CODE
# Second parameter: MESSAGE
displayerrorandexit() {
local exitcode=$1
shift
displayerror "$*"
exit $exitcode
}
# First parameter: MESSAGE
# Others parameters: COMMAND (! not |)
displayandexec() {
local message=$1
echo -n "[En cours] $message"
shift
echo ">>> $*" >> $LOG_FILE 2>&1
sh -c "$*" >> $LOG_FILE 2>&1
local ret=$?
if [ $ret -ne 0 ]; then
echo -e "\r\e[0;31m [ERROR]\e[0m $message"
else
echo -e "\r\e[0;32m [OK]\e[0m $message"
fi
return $ret
}
# Debut de la génération des logs
#-----------------------------------------------------------------------------
clear
displaytitle "ElementaryOS France log compilator"
displayandexec "Gathering PCI informations (you must be connected to the Internet)" "lspci -qq -Q > pci.txt"
displayandexec "Gathering last messages from dmesg" "dmesg -T -x > dmesg.txt"
displayandexec "Gathering informations from Lshw (needs temporary root privileges)" "gksudo lshw > lshw.txt"
# Fin du script