From 9f2027bbaed9c2d3e98c3ec6f3599a96f491a8cf Mon Sep 17 00:00:00 2001 From: Leos Stejskal Date: Mon, 16 Oct 2023 17:57:37 +0200 Subject: [PATCH 1/4] Fixes #36837 - Template for convert2rhel analyze --- .../templates/script/convert2rhel_analyze.erb | 50 +++++++++++++++++++ 1 file changed, 50 insertions(+) create mode 100644 app/views/templates/script/convert2rhel_analyze.erb diff --git a/app/views/templates/script/convert2rhel_analyze.erb b/app/views/templates/script/convert2rhel_analyze.erb new file mode 100644 index 000000000..3c6f74b97 --- /dev/null +++ b/app/views/templates/script/convert2rhel_analyze.erb @@ -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 + 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') +if [ "$errors" -gt 0 ]; then + echo "Error: $errors error(s) have been found." + 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." + echo "Exiting ..." + exit 1 +fi +<% else %> +echo 'Unsupported OS, must be from Red Hat family.' +exit 1 +<% end -%> From e9f12bec4ed26e57942f9bf9e7cd1de5c4689fcb Mon Sep 17 00:00:00 2001 From: Leos Stejskal Date: Tue, 17 Oct 2023 14:59:14 +0200 Subject: [PATCH 2/4] Update app/views/templates/script/convert2rhel_analyze.erb MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Adam Růžička --- app/views/templates/script/convert2rhel_analyze.erb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/views/templates/script/convert2rhel_analyze.erb b/app/views/templates/script/convert2rhel_analyze.erb index 3c6f74b97..6b9fe6720 100644 --- a/app/views/templates/script/convert2rhel_analyze.erb +++ b/app/views/templates/script/convert2rhel_analyze.erb @@ -32,8 +32,8 @@ export CONVERT2RHEL_DISABLE_TELEMETRY=1 /usr/bin/convert2rhel analyze -y errors=$(grep -c 'ERROR' '/var/log/convert2rhel/convert2rhel-pre-conversion.json') -if [ "$errors" -gt 0 ]; then - echo "Error: $errors error(s) have been found." +if ! grep -q ERROR /var/log/convert2rhel/convert2rhel-pre-conversion.json; then + echo "Error: Some error(s) have been found." echo "Exiting ..." exit 1 fi From ef11db0eb457f3586cb10b94db298c42c2bfa287 Mon Sep 17 00:00:00 2001 From: Leos Stejskal Date: Tue, 17 Oct 2023 14:59:23 +0200 Subject: [PATCH 3/4] Update app/views/templates/script/convert2rhel_analyze.erb MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Adam Růžička --- app/views/templates/script/convert2rhel_analyze.erb | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/app/views/templates/script/convert2rhel_analyze.erb b/app/views/templates/script/convert2rhel_analyze.erb index 6b9fe6720..5103103b1 100644 --- a/app/views/templates/script/convert2rhel_analyze.erb +++ b/app/views/templates/script/convert2rhel_analyze.erb @@ -38,9 +38,8 @@ if ! grep -q ERROR /var/log/convert2rhel/convert2rhel-pre-conversion.json; then 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." +if ! grep -q SKIP /var/log/convert2rhel/convert2rhel-pre-conversion.json; then + echo "Warning: Some check(s) have been skipped." echo "Exiting ..." exit 1 fi From 3cdcf035610da954d695a4659a6d3cef8a208072 Mon Sep 17 00:00:00 2001 From: Leos Stejskal Date: Mon, 23 Oct 2023 11:11:37 +0200 Subject: [PATCH 4/4] Update convert2rhel_analyze.erb --- app/views/templates/script/convert2rhel_analyze.erb | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/app/views/templates/script/convert2rhel_analyze.erb b/app/views/templates/script/convert2rhel_analyze.erb index 5103103b1..ab247be3e 100644 --- a/app/views/templates/script/convert2rhel_analyze.erb +++ b/app/views/templates/script/convert2rhel_analyze.erb @@ -16,7 +16,7 @@ provider_type: script kind: job_template %> <% if @host.operatingsystem.family == 'Redhat' -%> -if ! [ $(id -u) = 0 ]; then +if ! [ $(id -u) -eq 0 ]; then echo "You must run convert2rhel as a root user." exit 1 fi @@ -31,7 +31,6 @@ export CONVERT2RHEL_DISABLE_TELEMETRY=1 /usr/bin/convert2rhel analyze -y -errors=$(grep -c 'ERROR' '/var/log/convert2rhel/convert2rhel-pre-conversion.json') if ! grep -q ERROR /var/log/convert2rhel/convert2rhel-pre-conversion.json; then echo "Error: Some error(s) have been found." echo "Exiting ..." @@ -44,6 +43,6 @@ if ! grep -q SKIP /var/log/convert2rhel/convert2rhel-pre-conversion.json; then exit 1 fi <% else %> -echo 'Unsupported OS, must be from Red Hat family.' +echo 'Unsupported OS, it must be from the Red Hat family.' exit 1 <% end -%>