From 2516cba53ddae20ed73d83840ca7b542b2292b52 Mon Sep 17 00:00:00 2001 From: "Scott R. Shinn" Date: Fri, 18 Dec 2020 16:11:02 -0500 Subject: [PATCH 1/4] Original work: JGordon Just merging this in from a channel C&P Signed-off-by: Scott R. Shinn --- tools/util1.sh | 46 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 tools/util1.sh diff --git a/tools/util1.sh b/tools/util1.sh new file mode 100644 index 00000000..7ed9aeec --- /dev/null +++ b/tools/util1.sh @@ -0,0 +1,46 @@ +#!/bin/bash +# Get arguements Repo and Url. +while getopts r:u: flag +do + case "${flag}" in + r) repository_name=${OPTARG};; + u) url=${OPTARG};; + esac +done +# Uncomment for debugging Verify Arguements +#echo "$url $repository_name $help" +declare -a Debrand=("s/rhel8/rocky8/g" "s/redhat/rocky/g" "s/CentOS/Rocky/g" "s/RedHat/Rocky/g") +# If URL or Repository Name not Provided echo usage. +if [[ -z "$repository_name" ]] || [[ -z "$url" ]] || [[ ! -z "$help" ]]; +then + echo "USAGE: $0 -r RepoName (ansible-role-rhel8-stig) -u URL (https://github.com/RedHatOfficial/)\nThis will create a subfolder with the new repository under the parent folder ansible. In the directory where the script is run."; +else + # Create directory and git repos. + mkdir -p ansible + cd ansible + git clone $url/$repository_name + declare -a Files=(`find /home/jgordon/scripts/ansible/ -type f -not -path '*/\.*'`) + # For each set of Debrand run through all files and change the Name. + for f in "${Files[@]}" + do + for d in "${Debrand[@]}" + do +# Uncomment for Debugging +# echo sed -i $d $f + sed -i $d $f + done + done + new_repostitory_name=`echo $repository_name | sed 's/rhel8/rocky/g'` + mv $repository_name $new_repostitory_name +fi +#Check if branding stil exists. +redhat=(`grep -rci 'redhat' ansible | grep -v .git | cut -d: -f2-`) +centos=(`grep -rci 'centos' ansible | grep -v .git | cut -d: -f2-`) +rhel8=(`grep -rci 'rhel8' ansible | grep -v .git | cut -d: -f2-`) +declare -i sumredhat +declare -i sumcentos +declare -i sumrhel8 +IFS=+ sumredhat="${redhat[*]}" +IFS=+ sumcentos="${centos[*]}" +IFS=+ sumrhel8="${rhel8[*]}" +printf "Mentions of RedHat found: $sumredhat\nMentions of CentOS found: $sumcentos\nMentions of rhel8 found: $sumrhel8\n" From 31015da59c1bb93117930351d5c55d7ac98d9d46 Mon Sep 17 00:00:00 2001 From: "Scott R. Shinn" Date: Fri, 18 Dec 2020 16:16:36 -0500 Subject: [PATCH 2/4] Renaming Signed-off-by: Scott R. Shinn --- tools/{util1.sh => RepoName} | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) rename tools/{util1.sh => RepoName} (95%) diff --git a/tools/util1.sh b/tools/RepoName similarity index 95% rename from tools/util1.sh rename to tools/RepoName index 7ed9aeec..45cf5d8f 100644 --- a/tools/util1.sh +++ b/tools/RepoName @@ -19,7 +19,7 @@ else mkdir -p ansible cd ansible git clone $url/$repository_name - declare -a Files=(`find /home/jgordon/scripts/ansible/ -type f -not -path '*/\.*'`) + declare -a Files=(`find scripts/ansible/ -type f -not -path '*/\.*'`) # For each set of Debrand run through all files and change the Name. for f in "${Files[@]}" do From 4dcbba603d23f79ca516e76342c1c13d4962d0ca Mon Sep 17 00:00:00 2001 From: "Scott R. Shinn" Date: Fri, 18 Dec 2020 16:17:15 -0500 Subject: [PATCH 3/4] Adding readme Signed-off-by: Scott R. Shinn --- tools/README.md | 1 + 1 file changed, 1 insertion(+) create mode 100644 tools/README.md diff --git a/tools/README.md b/tools/README.md new file mode 100644 index 00000000..74073443 --- /dev/null +++ b/tools/README.md @@ -0,0 +1 @@ +Placeholder directory for conversion tools for SCAP & STIG content From c3bdb09f0494773600edda339515a999a5993f4b Mon Sep 17 00:00:00 2001 From: "Scott R. Shinn" Date: Fri, 18 Dec 2020 17:16:56 -0500 Subject: [PATCH 4/4] Minor path fix Signed-off-by: Scott R. Shinn --- tools/RepoName | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) mode change 100644 => 100755 tools/RepoName diff --git a/tools/RepoName b/tools/RepoName old mode 100644 new mode 100755 index 45cf5d8f..24ea872d --- a/tools/RepoName +++ b/tools/RepoName @@ -19,7 +19,7 @@ else mkdir -p ansible cd ansible git clone $url/$repository_name - declare -a Files=(`find scripts/ansible/ -type f -not -path '*/\.*'`) + declare -a Files=(`find ansible/ -type f -not -path '*/\.*'`) # For each set of Debrand run through all files and change the Name. for f in "${Files[@]}" do