feat: adding reposync wrapper and tooling
- add autosyncer/autopromoter scripts - add timer and service to initial sync process - add timer/service for daily/weekly/monthly autopromote - add define to manage each repo - add nginx webserver to share repos - add favion.ico if enabled - add selinux management, and packages for selinux - cleanup package management, sorting package groups into package classes
This commit is contained in:
@@ -0,0 +1,53 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
# Function to create symlink for snapshots
|
||||
create_symlink() {
|
||||
local osname="$1"
|
||||
local release="$2"
|
||||
local repository="$3"
|
||||
local basepath="$4"
|
||||
local label="$5" # 'monthly', 'weekly', or 'daily'
|
||||
local date_format="$6" # Date format for finding the snapshot
|
||||
|
||||
# The path where snapshots are stored
|
||||
local snap_path="${basepath}/snap/${osname}/${release}/${repository}-${date_format}"
|
||||
|
||||
# The target path for the symlink
|
||||
local symlink_target="${basepath}/snap/${osname}/${release}/${repository}-${label}"
|
||||
|
||||
# Check if the source directory exists
|
||||
if [[ -d "$snap_path" ]]; then
|
||||
# Create the symlink, overwrite if it already exists
|
||||
ln -sfn "$snap_path" "$symlink_target"
|
||||
echo "Symlink created for $snap_path -> $symlink_target"
|
||||
else
|
||||
echo "Snapshot path does not exist: $snap_path"
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
# Determine which snapshot to promote based on the passed argument
|
||||
case "$1" in
|
||||
monthly)
|
||||
promote_date=$(date --date="$(date +%Y%m01) -1 month" +%Y%m%d)
|
||||
;;
|
||||
weekly)
|
||||
promote_date=$(date --date="last Sunday" +%Y%m%d)
|
||||
;;
|
||||
daily)
|
||||
promote_date=$(date --date="yesterday" +%Y%m%d)
|
||||
;;
|
||||
*)
|
||||
echo "Usage: $0 {monthly|weekly|daily}"
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
|
||||
# Call the function with appropriate arguments
|
||||
# Iterate over the repositories to create symlinks for each
|
||||
for conf in /etc/reposync/conf.d/*.conf; do
|
||||
source "$conf"
|
||||
|
||||
# Create symlink based on the provided argument
|
||||
create_symlink "$OSNAME" "$RELEASE" "$REPOSITORY" "$BASEPATH" "$1" "$promote_date"
|
||||
done
|
||||
@@ -0,0 +1,97 @@
|
||||
#!/usr/bin/bash
|
||||
|
||||
# Function to perform reposync
|
||||
perform_reposync() {
|
||||
local reponame="$1"
|
||||
local basepath="$2"
|
||||
|
||||
/usr/bin/dnf reposync \
|
||||
--gpgcheck \
|
||||
--delete \
|
||||
--downloadcomps \
|
||||
--download-metadata \
|
||||
--remote-time \
|
||||
--disablerepo="*" \
|
||||
--enablerepo="${reponame}" \
|
||||
--download-path="${basepath}/live"
|
||||
}
|
||||
|
||||
# Function to download GPG keys
|
||||
download_gpg_key() {
|
||||
local gpgkeyurl="$1"
|
||||
local reponame="$2"
|
||||
local basepath="$3"
|
||||
|
||||
# Extract filename from URL
|
||||
local filename=$(basename "$gpgkeyurl")
|
||||
|
||||
# Download GPG key to the specified path with the filename from the URL
|
||||
wget -q -O "${basepath}/live/${reponame}/${filename}" "$gpgkeyurl" || {
|
||||
echo "Failed to download GPG key from $gpgkeyurl"
|
||||
}
|
||||
}
|
||||
|
||||
# Function to perform rsync with hard links
|
||||
perform_rsync() {
|
||||
local source_path="$1"
|
||||
local dest_path="$2"
|
||||
|
||||
# Create the destination directory if it doesn't exist
|
||||
mkdir -p "$dest_path"
|
||||
|
||||
# Use rsync to create hard links to the files in the destination directory
|
||||
rsync -a --link-dest="$source_path" "$source_path"/* "$dest_path"
|
||||
}
|
||||
|
||||
create_repo_metadata() {
|
||||
local basepath="${1}"
|
||||
local osname="${2}"
|
||||
local release="${3}"
|
||||
local repository="${4}"
|
||||
local current_date="${5}"
|
||||
|
||||
local repo_path="${basepath}/snap/${osname}/${release}/${repository}-${current_date}"
|
||||
|
||||
if [[ -d "$repo_path" ]]; then
|
||||
echo "Running createrepo on ${repo_path}..."
|
||||
createrepo --update "${repo_path}"
|
||||
if [[ $? -eq 0 ]]; then
|
||||
echo "Successfully created repository metadata for ${repository}"
|
||||
else
|
||||
echo "Failed to create repository metadata for ${repository}" >&2
|
||||
return 1
|
||||
fi
|
||||
else
|
||||
echo "The specified repository path does not exist: ${repo_path}" >&2
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
# Current date in the required format
|
||||
DATE=$(date +%Y%m%d)
|
||||
|
||||
# iterate over each configuration file
|
||||
for conf in /etc/reposync/conf.d/*.conf; do
|
||||
|
||||
# source the configuration to get the variables
|
||||
source "$conf"
|
||||
|
||||
# Call the function to download the GPG key
|
||||
download_gpg_key "$GPGKEYURL" "$REPONAME" "$BASEPATH"
|
||||
|
||||
# Call the reposync function
|
||||
perform_reposync "$REPONAME" "$BASEPATH"
|
||||
|
||||
# Path for rsync source
|
||||
live_path="${BASEPATH}/live/${REPONAME}"
|
||||
|
||||
# Path for rsync destination
|
||||
snap_path="${BASEPATH}/snap/${OSNAME}/${RELEASE}/${REPOSITORY}-${DATE}/${ARCH}/os"
|
||||
|
||||
# Call the rsync function
|
||||
perform_rsync "$live_path" "$snap_path"
|
||||
|
||||
# After syncing each repo, fix the repository metadata
|
||||
create_repo_metadata "${BASEPATH}" "${OSNAME}" "${RELEASE}" "${REPOSITORY}" "${DATE}"
|
||||
|
||||
done
|
||||
@@ -0,0 +1,8 @@
|
||||
# <%= @osname %>-<%= @release %>-<%= @repository %> repository configuration
|
||||
REPOSITORY="<%= @repository %>"
|
||||
REPONAME="<%= @repos_name %>"
|
||||
OSNAME="<%= @osname %>"
|
||||
RELEASE="<%= @release %>"
|
||||
ARCH="<%= @arch %>"
|
||||
BASEPATH="<%= @basepath %>"
|
||||
GPGKEYURL="<%= @gpgkey %>"
|
||||
Reference in New Issue
Block a user