-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathosshealth
134 lines (131 loc) · 4.85 KB
/
osshealth
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
#!/QOpenSys/usr/bin/sh
set -A WARNINGS
set -A ERRORS
function pass {
print "PASS"
}
function fail {
if [[ "$1" == "ERROR" ]]; then
>&2 echo FAILED
ERRORS[${#ERRORS[*]}+1]="$2"
else
>&2 echo WARNING
WARNINGS[${#WARNINGS[*]}+1]="$2"
fi
}
#
function check_contains {
print -n checking to be false\: "$2"...
if [[ $(sh -c "$3" 2>&1) == *"$4"* ]]; then
pass
else
fail "$1" "$2"
fi
}
function check_not_contains {
print -n checking to be false\: "$2"...
if [[ $(sh -c "$3" 2>&1) == *"$4"* ]]; then
fail "$1" "$2"
else
pass
fi
}
function check_no_exists {
print -n checking that "$2" does not exist...
if [ ! -e "$2" ]; then
pass
else
fail "$1" "$2 exists"
fi
}
function check_exists {
print -n checking that "$2" does exist...
if [ -e "$2" ]; then
pass
else
fail "$1" "$2 exists"
fi
}
function check_cmd_success {
print -n "$2"...
CMDOUT=$(sh -c "$3" 2>&1)
if [[ "$?" == 0 ]]; then
pass
else
echo "cmdout $CMDOUT"
fail "$1" "$2 failed: $CMDOUT"
fi
}
function check_yum_pkg {
print -n "checking that package '$2' is installed"...
CMDOUT=$(sh -c "/QOpenSys/pkgs/bin/yum list installed $2" 2>&1)
if [[ "$?" == 0 ]]; then
pass
else
echo "cmdout $CMDOUT"
fail "$1" "Package not installed: $2"
fi
}
check_contains "ERROR" "PATH does not contain /QOpenSys/pkgs/bin" "echo $PATH" "/QOpenSys/pkgs/bin"
check_not_contains "ERROR" "PATH contains /opt/freeware/bin" "echo $PATH" "/opt/freeware/bin"
check_contains "ERROR" "Not using proper RPM" "which rpm" "/QOpenSys/pkgs/bin/rpm"
check_contains "WARNING" "Not using bash" "ps" "bash"
check_contains "ERROR" "Not using GNU coreutils (may need to install 'coreutils-gnu' package or adjust PATH)" "which ls" "/QOpenSys/pkgs/bin/ls"
check_contains "WARNING" "5733OPS is still installed" "/QOpenSys/usr/bin/system 'QSYS/CHKPRDOPT PRDID(5733OPS) OPTION(*BASE)'" "CPF0C4A"
check_no_exists "WARNING" "/opt/freeware/bin/rpm"
check_no_exists "WARNING" "/opt/freeware/bin/yum"
check_no_exists "ERROR" "/usr/bin/gcc"
check_no_exists "ERROR" "/QOpenSys/usr/bin/gcc"
check_no_exists "ERROR" "/opt/freeware/bin/yum"
check_exists "ERROR" "/QOpenSys/pkgs/bin/readlink"
check_exists "ERROR" "/QOpenSys/pkgs/bin/yum"
check_exists "ERROR" "/QOpenSys/pkgs/bin/rpm"
check_exists "ERROR" "/QOpenSys/pkgs/bin/bash"
check_not_contains "ERROR" "Using 5733OPS Python" "/QOpenSys/pkgs/bin/readlink -f `which python`" "/QOpenSys/QIBM"
check_not_contains "ERROR" "Using 5733OPS Python 3" "/QOpenSys/pkgs/bin/readlink -f `which python3`" "/QOpenSys/QIBM"
check_not_contains "ERROR" "Using 5733OPS Python 2" "/QOpenSys/pkgs/bin/readlink -f `which python2`" "/QOpenSys/QIBM"
check_not_contains "ERROR" "Using AIX Python" "/QOpenSys/pkgs/bin/readlink -f `which python`" "/opt/freeware/bin/python"
check_not_contains "ERROR" "Using AIX Python 2" "/QOpenSys/pkgs/bin/readlink -f `which python2`" "/opt/freeware/bin/python2"
check_not_contains "ERROR" "Using AIX Python 3" "/QOpenSys/pkgs/bin/readlink -f `which python3`" "/opt/freeware/bin/python3"
check_not_contains "ERROR" "Using AIX RPM" "/QOpenSys/pkgs/bin/readlink -f `which rpm`" "/opt/freeware/bin/rpm"
check_not_contains "ERROR" "Using AIX bash" "/QOpenSys/pkgs/bin/readlink -f `which bash`" "/opt/freeware/bin/bash"
check_not_contains "ERROR" "Using AIX git" "/QOpenSys/pkgs/bin/readlink -f `which git`" "/opt/freeware/bin/git"
check_contains "ERROR" "Using AIX curl" "/QOpenSys/pkgs/bin/readlink -f `which curl`" "/QOpenSys/pkgs/bin/curl"
check_not_contains "ERROR" "Using 5733OPS node" "/QOpenSys/pkgs/bin/readlink -f `which node`" "/QOpenSys/QIBM"
check_not_contains "ERROR" "Using 5733OPS npm" "/QOpenSys/pkgs/bin/readlink -f `which npm`" "/QOpenSys/QIBM"
check_not_contains "ERROR" "Using 5733OPS bash" "/QOpenSys/pkgs/bin/readlink -f `which bash`" "/QOpenSys/QIBM"
check_not_contains "WARNING" "Using PASE tar (may want to install tar-gnu)" "which tar" "/QOpenSys/usr/bin/tar"
check_cmd_success "ERROR" "RPM database sanity check" "/QOpenSys/pkgs/bin/yum check"
check_yum_pkg "WARNING" "ca-certificates-mozilla"
check_yum_pkg "ERROR" "bash"
check_yum_pkg "ERROR" "coreutils-gnu"
print " "
print " "
print " "
print " "
print " "
print " "
print "============================================"
print " Summary:"
print " ${#ERRORS[*]} errors, ${#WARNINGS[*]} warnings"
print " "
if [[ "${#WARNINGS[*]}" != "0" ]]; then
print " The following warnings were discovered:"
i=1
while [ $i -le ${#WARNINGS[@]} ]
do
print " - " ${WARNINGS[$i]}
(( i=i+1 ))
done
print " "
fi
if [[ "${#ERRORS[*]}" != "0" ]]; then
print " The following errors were discovered:"
i=1
while [ $i -le ${#ERRORS[@]} ]
do
print " - " ${ERRORS[$i]}
(( i=i+1 ))
done
print " "
fi