#!/bin/bash #DESC This script will run on any redhat version and will create or sync redhat yum repos for 8,9 and 10 on one server. No redhat account or license needed. #DESC redhat containers source (look for the unauthenticated versions): https://catalog.redhat.com/en/software/containers/explore #verify root [ $ID -ne 0 ] && echo "You must be root to run $0." && exit 1 #install or update deps yum install -y httpd podman systemctl enable httpd for OS in "rhel8 rhel9 rhel10" do #start container [ "$OS" == "rhel8" ] && CONTAINER=`podman run -d -it -h rhel8-repo.myk.sh --name=rhel8-repo.myk.sh --rm --privileged -v "/var/www/html:/var/www/html" -v /sys/fs/cgroup:/sys/fs/cgroup:ro -w="/var/www/html" -i registry.access.redhat.com/ubi8/ubi:8.10-1786322297 /usr/bin/bash` [ "$OS" == "rhel9" ] && CONTAINER=`podman run -d -it -h rhel9-repo.myk.sh --name=rhel9-repo.myk.sh --rm --privileged -v "/var/www/html:/var/www/html" -v /sys/fs/cgroup:/sys/fs/cgroup:ro -w="/var/www/html" -i registry.access.redhat.com/ubi9/ubi:9.8-1786631889 /usr/bin/bash` [ "$OS" == "rhel10" ] && CONTAINER=`podman run -d -it -h rhel10-repo.myk.sh --name=rhel10-repo.myk.sh --rm --privileged -v "/var/www/html:/var/www/html" -v /sys/fs/cgroup:/sys/fs/cgroup:ro -w="/var/www/html" -i registry.access.redhat.com/ubi10/ubi:1786398434 /usr/bin/bash` #install package with reposync podman exec $CONTAINER yum -y install yum-utils #sync repos [ "$OS" == "rhel8" ] && podman exec $CONTAINER reposync -p /var/www/html --download-metadata --repo=rhel-8-for-x86_64-baseos-rpms [ "$OS" == "rhel8" ] && podman exec $CONTAINER reposync -p /var/www/html --download-metadata --repo=rhel-8-for-x86_64-appstream-rpms [ "$OS" == "rhel9" ] && podman exec $CONTAINER reposync -p /var/www/html --download-metadata --repo=rhel-9-for-x86_64-baseos-rpms [ "$OS" == "rhel9" ] && podman exec $CONTAINER reposync -p /var/www/html --download-metadata --repo=rhel-9-for-x86_64-appstream-rpms [ "$OS" == "rhel10" ] && podman exec $CONTAINER reposync -p /var/www/html --download-metadata --repo=rhel-10-for-x86_64-baseos-rpms [ "$OS" == "rhel10" ] && podman exec $CONTAINER reposync -p /var/www/html --download-metadata --repo=rhel-10-for-x86_64-appstream-rpms #shutdown container podman container rm -f $CONTAINER done echo "Done!...." exit $?