User Tools

Site Tools


re-build_repository_index

Rebuild repository index (YUM)

this script will regenerate repository index.

#!/bin/bash
#
# Regenerate index for all High level folders in Repository.
# You can specify Location for repository in array.
#
# Developed by k2patel (k2patel@hotmail.com)
# For rpm.k2patel.in
#^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
 
 
# Add all location for repository.
 
Location=(/var/www/html/RHEL/6 /var/www/html/EPEL/5 /var/www/html/EPEL/6 /var/www/html/puppet/el6)
 
## Do not modify further ##
 
for index in ${!Location[*]}
do
    for dir in `ls ${Location[$index]}`
        do
          if [ -d ${Location[$index]}/$dir ]; then
            echo -n "Rebuilding index for ${Location[$index]}/$dir....."
            createrepo --update ${Location[$index]}/$dir
            echo "Done"
          else
            echo "Not a valid folder : ${Location[$index]}/$dir"
          fi
        done
done

<note warning>If you are using mix versions of OS Version it is advisable to add switch “-s sha” or “-s md5”. As from EL6 to EL5 it could cause error “[Errno -3] Error performing checksum” </note>

re-build_repository_index.txt · Last modified: 2020/08/10 02:35 (external edit)