From 556985e4fd9111b4df1e99b2f1ba966d152a9212 Mon Sep 17 00:00:00 2001 From: Bryan Date: Wed, 8 Dec 2021 22:43:49 -0500 Subject: [PATCH] added setup local repo --- docs/gemstones/setup_local_repo.md | 43 ++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 docs/gemstones/setup_local_repo.md diff --git a/docs/gemstones/setup_local_repo.md b/docs/gemstones/setup_local_repo.md new file mode 100644 index 0000000000..529a605938 --- /dev/null +++ b/docs/gemstones/setup_local_repo.md @@ -0,0 +1,43 @@ +--- +title: Setup Local Rocky Linux Repositories +Author: codedude +--- + +# Introduction +Sometimes you need to have Rocky Repositories local for building virtual machines, lab environments, etc. It can also can help save bandwidth if that is a concern. This article will walk you thru using rsync to copy Rocky repositories to a local web server. Building a web server is out of the scope of this short article. + +## Requirements +A web server + +## Code +``` +#!/bin/bash +repos_base_dir="/web/path" + +# Start sync if base repo directory exist +if [[ -d "$repos_base_dir" ]] ; then + # Start Sync + rsync -avSHP --progress --delete --exclude-from=/opt/scripts/excludes.txt rsync://ord.mirror.rackspace.com/rocky "$repos_base_dir" --delete-excluded + # Download Rocky 8 repository key + if [[ -e /web/path/RPM-GPG-KEY-rockyofficial ]]; then + exit + else + wget -P $repos_base_dir https://dl.rockylinux.org/pub/rocky/RPM-GPG-KEY-rockyofficial + fi +fi +``` +## Breakdown +This simple shell script uses rsync to pull repository files from the nearest mirror. It also utilizes the "exclude" option which is defined in a text file in the form of keywords that shouldnt be included. Excludes are good if you have limited disk space or just dont want everything for whatever reason. We can use '*' as a wildcard character. Be careful using '*/ng' as it will exclude anything that match those characters. An example is below. + +``` +*/source* +*/debug* +*/images* +*/Devel* +8/* +8.4-RC1/* +8.4-RC1 +``` + +# End +A simple script that can help save bandwidth or make building out a lab environment a little easier.