forked from Qikfix/RepoLocator
-
Notifications
You must be signed in to change notification settings - Fork 0
/
repolocator.sh
53 lines (40 loc) · 1.09 KB
/
repolocator.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
#!/bin/bash
check_hammer(){
# exit out the script if not login to registry.redhat.io
timeout --foreground -k 1 5 hammer organization list > /dev/null 2>&1
if [ $? != 0 ]
then
echo "Please check hammer login is valid."
exit 1
fi
}
complete()
{
REPO="/tmp/repolocator.repolist.txt"
CV="/tmp/repolocator.cvlist.txt"
OUTPUT="/tmp/repolocator-output.txt"
#remove any preivous repolocator-output.txt files
> $OUTPUT
#Cleanup from prior runs
for i in $REPO $CV ; do
if [ -f $i ] ; then
/bin/rm $i || exit $?
fi
done
#Extract needed info
/usr/bin/hammer --csv repository list > $REPO || exit $?
/usr/bin/hammer --csv content-view list > $CV || exit $?
FULL=$(cat $REPO | cut -d, -f1,2 | sed '1d')
ID=$(cat $REPO | cut -d, -f1 | sed '1d')
for b in $ID
do
echo - "Repo ID ....: $b" >> $OUTPUT
echo - "Repo Name ..: $(echo "$FULL" | grep ^$b, | cut -d, -f2)" >> $OUTPUT
cat $CV | grep -E "(\"$b,| $b,| $b\")" | cut -d, -f1,2 >> $OUTPUT
echo >> $OUTPUT
done
echo "Please upload $OUTPUT"
/bin/rm $REPO $CV
}
check_hammer
complete