-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathsetupsos
More file actions
executable file
·61 lines (61 loc) · 1.62 KB
/
setupsos
File metadata and controls
executable file
·61 lines (61 loc) · 1.62 KB
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
#!/bin/bash
# Setup the sosreport environment and check to see if we have seen this system before
# Written by Kyle Walker kwalker@redhat.com
export CASENUM=`echo $PWD|grep -Eo '[0-9]{8}'`
export KNOWN=0
checksysknown() {
if [[ ! -e ~/knownsystems ]]; then
touch ~/knownsystems
echo 'First run, initializing system listings'
fi
if [ ! -d $PWD/work/ ]; then
mkdir $PWD/work/
fi
x=$(grep $SYSHOSTNAME ~/knownsystems -c)
if [ $x -gt 0 ]; then
KNOWN=1
if [[ ! -e $PWD/work/report.history || `grep $SYSHOSTNAME $PWD/work/report.history -c 2>/dev/null` -eq 0 ]]; then
grep $SYSHOSTNAME ~/knownsystems >> $PWD/work/report.history
fi
if [[ `grep $CASENUM ~/knownsystems -c` -eq 0 ]]; then
echo "$SYSHOSTNAME $CASENUM" >> ~/knownsystems
fi
else
KNOWN=0
echo "$SYSHOSTNAME $CASENUM" >> ~/knownsystems
fi
}
for i in `ls *.tar* 2>/dev/null | grep -Eve md5`
do
tar xf $i
if [ ! -d $PWD/archive ]; then
mkdir $PWD/archive
fi
#mv $i $PWD/archive/$i
touch $PWD/archive/$i
rm -f $i
done
for i in `ls -d */`;
do
if [ -e $i/date ]; then
DESTFILE=`cat $i/hostname | awk -F '.' '/^[[:alpha:]]/ {print $1}'`-`cat $i/date | grep '^[a-Z]' | tr -s ' ' | sed 's/ /-/g' | awk -F "-" '{print $NF"-"$2"-"$3"-"$4}'`
if [ ! -d $DESTFILE ]; then
mv $i $DESTFILE
fi
fi
done
for i in `ls -d */`
do
export HOSTNAMEFILE="$i/hostname"
if [ -e $HOSTNAMEFILE ]; then
export SYSHOSTNAME=`cat $HOSTNAMEFILE | cut -d '.' -f 1`
else
continue
fi
checksysknown
if [ $KNOWN -eq 1 ]; then
echo -e "\tKnown system: Report generated and located in work directory"
else
echo -e "\tUnknown system: Added to database"
fi
done