# Sync CentOS Repos for internal patch management # Created by admin # Last modified: 1-30-2016 #!/bin/bash # Get info about the current system OS_VER=`cat /etc/system-release-cpe |cut -d : -f5 |cut -c1` # should return value of redhat/centos etc DISTRO=`cat /etc/system-release-cpe |cut -d : -f3` # Mirror list https://www.centos.org/download/mirrors/ # Find an FTP mirror near you REGIONAL_MIRROR='mirrors.mit.edu/centos/' # Use lftp to sync CENTOS os repo cd /var/www/html/repo/centos/${OS_VER}/os/x86_64/Packages/ lftp -e 'open ftp://'"${REGIONAL_MIRROR}"'/'"${OS_VER}"'/os/x86_64/Packages/ && mirror -c --delete && exit' # Log message when completed logger sync_repo CENTOS${OS_VER} os package repo synced # Use lftp to sync CENTOS updates repo cd /var/www/html/repo/centos/${OS_VER}/updates/x86_64/Packages/ lftp -e 'open ftp://'"${REGIONAL_MIRROR}"'/'"${OS_VER}"'/updates/x86_64/Packages/ && mirror -c --delete && exit' # Log message when completed logger sync_repo CENTOS${OS_VER} updates package repo synced # Update repo metadata createrepo --workers=4 --update /var/www/html/repo/centos/${OS_VER}/os/x86_64/Packages createrepo --workers=4 --update /var/www/html/repo/centos/${OS_VER}/updates/x86_64/Packages # Log message when completed logger sync_repo Package repo metadata updated on el${OS_VER} repo server # Dump contents for versioning info maybe send to git or svn later ls /var/www/html/repo/centos/${OS_VER}/os/x86_64/Packages/ >> /var/www/html/repo/Package_Diff/centos-os-packages-"$(date '+%m-%d-%Y')".txt ls /var/www/html/repo/centos/${OS_VER}/updates/x86_64/Packages/ >> /var/www/html/repo/Package_Diff/centos-updates-packages-"$(date '+%m-%d-%Y')".txt