forked from openshift/oadp-operator
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcheck_prerequisites.sh
More file actions
executable file
·103 lines (89 loc) · 3.83 KB
/
Copy pathcheck_prerequisites.sh
File metadata and controls
executable file
·103 lines (89 loc) · 3.83 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
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
#!/bin/bash
INSTALLSAMPLE="${INSTALLSAMPLE:-false}"
############################################################
# Help #
############################################################
Help()
{
# Display Help
echo "Check the prerequisites for the OADP non-admin demo"
echo
echo "Check the prerequisites [-h|-i]"
echo "options:"
echo "h Print this Help."
echo
}
############################################################
############################################################
# Main program #
############################################################
############################################################
# Process the input options. Add options as needed. #
############################################################
# Get the options
while getopts "h:i" option; do
case $option in
h) # display Help
Help
exit;;
i) # Enter a demo user base name
INSTALLSAMPLE="true";;
\?) # Invalid option
echo "Error: Invalid option"
Help
exit;;
esac
done
TKN_INSTALLED=0
OADP_INSTALLED=0
OADP_CONFIGURED=0
if ! type oc > /dev/null 2>&1; then
echo "oc command not found, please install it in your PATH and log in to the OpenShift cluster to continue..."
exit 1
fi
if ! type jq > /dev/null 2>&1; then
echo "jq command not found, please install it in your PATH to continue..."
exit 1
fi
if ! oc auth can-i '*' '*' --all-namespaces >/dev/null 2>&1; then
echo "You must be logged in to a OpenShift cluster as a user with cluster-admin to continue..."
exit 1
fi
printf "Checking if the Openshift Pipelines operator is installed...\n"
printf "$ oc get crds tektonpipelines.operator.tekton.dev\n"
oc get crds tektonpipelines.operator.tekton.dev && TKN_INSTALLED=1
printf "Checking if OADP is installed and configured....\n"
printf "$ oc get operator oadp-operator.openshift-adp\n"
if oc get operator | grep -q oadp-operator.openshift-adp; then
OADP_INSTALLED=1
printf "Checking if there is configured at least one DataProtectionApplication Custom Resource...\n"
printf "$ oc get dpa -n openshift-adp -o jsonpath={.items} | jq '. | length'\n"
drc=$(oc get dpa -n openshift-adp -o jsonpath={.items} | jq '. | length')
if [ $drc -ge 1 ]; then
OADP_CONFIGURED=1
fi
fi
function print_tkn_not_installed() {
printf "\n\t* Install OpenShift Pipelines (Tekton):\n"
printf "\n\t https://docs.openshift.com/container-platform/latest/cicd/pipelines/installing-pipelines.html\n"
}
function print_oadp_not_installed() {
printf "\n\t* Install OADP Operator:\n"
printf "\n\t https://docs.openshift.com/container-platform/4.12/backup_and_restore/application_backup_and_restore/installing/about-installing-oadp.html\n"
}
function print_oadp_not_configured() {
printf "\n\t* Configure OADP DataProtectionApplication Custom Resource named 'dpa-sample':\n"
printf "\n\t https://github.com/openshift/oadp-operator/blob/oadp-dev/docs/install_olm.md#create-the-dataprotectionapplication-custom-resource"
}
printf "\n######################"
printf "\nSummary:"
printf "\n\t Tekton installed:\t%s" "$([ "$TKN_INSTALLED" -eq 1 ] && echo "True" || echo "False")"
printf "\n\t OADP installed:\t%s" "$([ "$OADP_INSTALLED" -eq 1 ] && echo "True" || echo "False")"
printf "\n\t OADP configured:\t%s" "$([ "$OADP_CONFIGURED" -eq 1 ] && echo "True" || echo "False")"
[ "$TKN_INSTALLED" -eq 1 ] && [ "$OADP_INSTALLED" -eq 1 ] && [ "$OADP_CONFIGURED" -eq 1 ] || printf "\n\nActions needed:"
[ "$TKN_INSTALLED" -eq 1 ] || print_tkn_not_installed
[ "$OADP_INSTALLED" -eq 1 ] || print_oadp_not_installed
[ "$OADP_CONFIGURED" -eq 1 ] || print_oadp_not_configured
printf "\n######################\n"
[ "$TKN_INSTALLED" -eq 1 ] && [ "$OADP_INSTALLED" -eq 1 ] && [ "$OADP_CONFIGURED" -eq 1 ]
exit $?