====== Repositories management ====== * synchronization #!/bin/bash BW_LIMIT=4000 MIRRORS_PATH="/var/mirrors" RSYNC="rsync -avHz --delete --stats --bwlimit=$BW_LIMIT" MENU_ITEM=( centos6 centos7 ubuntu14 exit ) intro() { echo "This script have been designed to create local repository of centOS 6,7 and ubuntu 14.04 LTS" read -n 1 -p "Press any key to continue" clear } main() { echo "#############" echo "# Main menu #" echo "#############" echo "" echo "Choose your distribution" select CHOICE in ${MENU_ITEM[@]}; do case $CHOICE in "centos6") create_centos_repo 6 ;; "centos7") create_centos_repo 7 ;; "ubuntu14") create_ubuntu_repo ;; "exit") echo "You choose to exit" exit 0 ;; *) echo "Not available distribution" exit -1 ;; esac done } create_centos_repo() { RELEASE="$1" ARCHS="i386 x86_64" CENTOS_MIRROR="rsync://centos.mirrors.ovh.net/ftp.centos.org/" BASE_LIST=" os updates centosplus extras" for ARCH in $ARCHS do for BASE in $BASE_LIST do REMOTE=$CENTOS_MIRROR/$RELEASE/$BASE/$ARCH/ if [ ! -e $MIRRORS_PATH/$RELEASE/$BASE/$ARCH ] then mkdir -p "$MIRRORS_PATH/$RELEASE/$BASE/$ARCH" fi $RSYNC $REMOTE $MIRRORS_PATH/$RELEASE/$BASE/$ARCH/ done done echo "`date +%x-%R` - Finished CentOS $RELEASE Mirror Sync" } create_ubuntu_repo() { UBUNTU_MIRROR="rsync://archive.ubuntu.com/ubuntu" mkdir -p $MIRRORS_PATH/ubuntu $RSYNC $EXCLUDE $UBUNTU_MIRROR $MIRRORS_PATH/ubuntu echo "`date +%x-%R` - Finished Ubuntu Mirror Sync" } intro main