-
Notifications
You must be signed in to change notification settings - Fork 83
/
check_linux_version.awk
151 lines (145 loc) · 3.32 KB
/
check_linux_version.awk
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
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
# ***********************************************************************
# * $Id: check_linux_version.awk 82180 2018-02-02 05:50:08Z hess $
# **********************************************************************
BEGIN {
checked = 0;
PACKAGE_FILE = "linux_package";
VERION_FILE = "linux_version";
}
# Check Linux Version Script For Linux Clones.
{
if (tolower($0) ~ /turbolinux/)
{
printf("turbolinux") > PACKAGE_FILE
printf GetVersion($0) > VERION_FILE
checked = 1;
}
else
if (tolower($0) ~ /red*hat*enterprise/ || tolower($0) ~ /red *hat *enterprise/)
{
printf("redhat_Enterprise") > PACKAGE_FILE
printf GetKind($0) > VERION_FILE
printf GetVersion($0) >> VERION_FILE
checked = 1;
}
else
if (tolower($0) ~ /red*hat/ || tolower($0) ~ /red *hat/)
{
printf("redhat") > PACKAGE_FILE
printf GetVersion($0) > VERION_FILE
checked = 1;
}
else
if (tolower($0) ~ /wowlinux/)
{
printf("wowlinux") > PACKAGE_FILE
printf GetVersion($0) > VERION_FILE
checked = 1;
}
else
if (tolower($0) ~ /hancom/)
{
printf("hancom") > PACKAGE_FILE;
printf GetVersion($0) > VERION_FILE;
checked = 1;
}
else
if (tolower($0) ~ /suse/ || tolower($0) ~ /s\.u\.s\.e/)
{
printf("suse") > PACKAGE_FILE
printf GetVersion($0) > VERION_FILE
checked = 1;
}
else
if (tolower($0) ~ /caldera/)
{
printf("caldera") > PACKAGE_FILE
printf GetVersion($0) > VERION_FILE
checked = 1;
}
else
if (tolower($0) ~ /mandrake/)
{
printf("mandrake") > PACKAGE_FILE
printf GetVersion($0) > VERION_FILE
checked = 1;
}
else
if (tolower($0) ~ /booyo/)
{
printf("booyo") > PACKAGE_FILE
printf GetVersion($0) > VERION_FILE
checked = 1;
}
else
if (tolower($0) ~ /asianux/)
{
printf("asianux") > PACKAGE_FILE
printf GetVersion($0) > VERION_FILE
checked = 1;
}
else
if (tolower($0) ~ /ubuntu/)
{
printf("ubuntu") > PACKAGE_FILE
printf GetVersion($0) > VERION_FILE
checked = 1;
}
else
if (tolower($0) ~ /ginux/)
{
printf("ginux") > PACKAGE_FILE
printf GetVersion($0) > VERION_FILE
checked = 1;
}
else
if (tolower($0) ~ /fedora/)
{
printf("fedora") > PACKAGE_FILE
printf GetVersion($0) > VERION_FILE
checked = 1;
}
else
if (tolower($0) ~ /linux mint/)
{
printf("mint") > PACKAGE_FILE
printf GetVersion($0) > VERION_FILE
checked = 1;
}
else
if (tolower($0) ~ /centos/)
{
printf("centos") > PACKAGE_FILE
printf GetVersion($0) > VERION_FILE
checked = 1;
}
}
END {
if (checked == 0)
{
printf("Unknown") > PACKAGE_FILE;
printf("Unknown") > VERION_FILE;
}
}
function GetKind(str)
{
for (i = 1; i <= NF; i++)
{
if ( $i ~ /[AaWwEe][Ss]/ )
{
return $i;
}
}
return "Unknown";
}
function GetVersion(str)
{
for (i = 1; i <= NF; i++)
{
if ( $i ~ /[0-9]+.?[0-9]*[a-zA-Z]*/)
{
return $i;
}
}
return "Unknown";
}