Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes #36837 - Template for convert2rhel analyze #840

Merged
merged 4 commits into from
Oct 23, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 50 additions & 0 deletions app/views/templates/script/convert2rhel_analyze.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
<%#
name: Convert2RHEL analyze
snippet: false
template_inputs:
- name: Data telemetry
required: false
input_type: user
options: "yes\r\nno"
advanced: false
value_type: plain
default: 'yes'
hidden_value: false
model: JobTemplate
job_category: Convert 2 RHEL
provider_type: script
kind: job_template
%>
<% if @host.operatingsystem.family == 'Redhat' -%>
if ! [ $(id -u) = 0 ]; then
stejskalleos marked this conversation as resolved.
Show resolved Hide resolved
echo "You must run convert2rhel as a root user."
exit 1
fi

if ! rpm -q convert2rhel &> /dev/null; then
yum install -y convert2rhel
fi

<% if input('Data telemetry') != "yes" -%>
export CONVERT2RHEL_DISABLE_TELEMETRY=1
<% end -%>

/usr/bin/convert2rhel analyze -y

errors=$(grep -c 'ERROR' '/var/log/convert2rhel/convert2rhel-pre-conversion.json')
stejskalleos marked this conversation as resolved.
Show resolved Hide resolved
if [ "$errors" -gt 0 ]; then
echo "Error: $errors error(s) have been found."
adamruzicka marked this conversation as resolved.
Show resolved Hide resolved
stejskalleos marked this conversation as resolved.
Show resolved Hide resolved
echo "Exiting ..."
exit 1
fi

skips=$(grep -c 'SKIP' '/var/log/convert2rhel/convert2rhel-pre-conversion.json')
if [ "$skips" -gt 0 ]; then
echo "Warning: $skips check(s) have been skipped."
stejskalleos marked this conversation as resolved.
Show resolved Hide resolved
echo "Exiting ..."
exit 1
fi
<% else %>
echo 'Unsupported OS, must be from Red Hat family.'
exit 1
<% end -%>
Loading