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
|
||||
Reference in New Issue
Block a user