From 79bcbcfa4efa4838af6fdf242404fb3f73ed0db1 Mon Sep 17 00:00:00 2001 From: Joshua Gordon Date: Fri, 18 Dec 2020 14:34:33 -0700 Subject: [PATCH 1/2] Adding debranding folder --- debrand/README.md | 0 debrand/scap-ansible-debrand.sh | 50 +++++++++++++++++++++++++++++++++ 2 files changed, 50 insertions(+) create mode 100644 debrand/README.md create mode 100644 debrand/scap-ansible-debrand.sh diff --git a/debrand/README.md b/debrand/README.md new file mode 100644 index 00000000..e69de29b diff --git a/debrand/scap-ansible-debrand.sh b/debrand/scap-ansible-debrand.sh new file mode 100644 index 00000000..5460a51d --- /dev/null +++ b/debrand/scap-ansible-debrand.sh @@ -0,0 +1,50 @@ +#!/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" "s/Red\ Hat/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 f969d8e0e3bd6939232c07909b376ecafb70fdc9 Mon Sep 17 00:00:00 2001 From: Joshua Gordon Date: Fri, 18 Dec 2020 14:56:24 -0700 Subject: [PATCH 2/2] Changed folders and names to match atomicturtle and fixed a script issue so it can be run directly from the repo main directory. --- ansible/ansible-role-rocky-stig | 1 + {debrand => tools}/README.md | 0 tools/RepoName | 50 +++++++++++++++++++ .../scap-ansible-debrand2.sh | 8 +-- 4 files changed, 53 insertions(+), 6 deletions(-) create mode 160000 ansible/ansible-role-rocky-stig rename {debrand => tools}/README.md (100%) create mode 100644 tools/RepoName rename debrand/scap-ansible-debrand.sh => tools/scap-ansible-debrand2.sh (91%) diff --git a/ansible/ansible-role-rocky-stig b/ansible/ansible-role-rocky-stig new file mode 160000 index 00000000..bd8729b8 --- /dev/null +++ b/ansible/ansible-role-rocky-stig @@ -0,0 +1 @@ +Subproject commit bd8729b813bcbaef433d14338bda6e3942a2b3c8 diff --git a/debrand/README.md b/tools/README.md similarity index 100% rename from debrand/README.md rename to tools/README.md diff --git a/tools/RepoName b/tools/RepoName new file mode 100644 index 00000000..2d198d12 --- /dev/null +++ b/tools/RepoName @@ -0,0 +1,50 @@ +#!/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 . -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' | grep -v .git | cut -d: -f2-`) +centos=(`grep -rci 'centos' | grep -v .git | cut -d: -f2-`) +rhel8=(`grep -rci 'rhel8' | 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" diff --git a/debrand/scap-ansible-debrand.sh b/tools/scap-ansible-debrand2.sh similarity index 91% rename from debrand/scap-ansible-debrand.sh rename to tools/scap-ansible-debrand2.sh index 5460a51d..45cf5d8f 100644 --- a/debrand/scap-ansible-debrand.sh +++ b/tools/scap-ansible-debrand2.sh @@ -9,9 +9,7 @@ do 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" "s/Red\ Hat/Rocky/g") - +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 @@ -21,8 +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 @@ -31,7 +28,6 @@ else # 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'`