-
Notifications
You must be signed in to change notification settings - Fork 1
/
getuserbydistro.sh
83 lines (80 loc) · 2.01 KB
/
getuserbydistro.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
getuserbydistro ()
{
distro="${1:-}"
name="${2:-}"
if echo $distro $name | grep windows > /dev/null 2>&1
then
echo Administrator
return
fi
if echo $distro $name | grep ubuntu1604-power8 > /dev/null 2>&1
then
echo root
return
fi
if echo $distro $name | grep ubuntu1604-zseries > /dev/null 2>&1
then
echo mci-exec
return
fi
if echo $distro $name | grep suse12-zseries > /dev/null 2>&1
then
echo mci-exec
return
fi
if echo $distro $name | grep suse11-zseries > /dev/null 2>&1
then
echo mci-exec
return
fi
if echo $distro $name | grep ubuntu > /dev/null 2>&1
then
echo ubuntu
return
fi
if echo $distro $name | grep solaris > /dev/null 2>&1
then
echo mci
return
fi
if echo $distro $name | grep debian > /dev/null 2>&1
then
echo admin
return
fi
if echo $distro $name | grep osx > /dev/null 2>&1
then
echo mci
return
fi
if echo $distro $name | grep centos6-perf > /dev/null 2>&1
then
echo mci-perf-exec
return
fi
if echo $distro $name | grep amazon > /dev/null 2>&1
then
echo ec2-user
return
fi
if echo $distro $name | grep amzn > /dev/null 2>&1
then
echo ec2-user
return
fi
if echo $distro $name | grep suse > /dev/null 2>&1
then
echo ec2-user
return
fi
user=$(
grep -l ^$distro: ~/git/mci/config_prod/distros.yml* ~/git/mci/config_prod/distros/* ~/distros.yml* | xargs egrep --no-filename ^$distro:\|user: | grep -A 1 ^$distro: | grep -v ^$distro: | grep -v -- -- | tail -1 | cut -f2 -d: | tr -d " "
)
if [ ! "$user" ]
then
user=$(
grep -l ^$distro: ~/git/mci/config_prod/distros.yml* ~/git/mci/config_prod/distros/* ~/distros.yml* | xargs egrep --no-filename ^$distro:\|user: | grep -B 1 ^$distro: | grep -v ^$distro: | grep -v -- -- | head -1 | cut -f2 -d: | tr -d " "
)
fi
echo "$user"
}