Sha256: 52e16bb5f972e912ac5ad6602c98b1244bb83767f43e9e800c9eb50920bc4bc3
Contents?: true
Size: 1.06 KB
Versions: 15
Compression:
Stored size: 1.06 KB
Contents
namespace :katello do desc "Cleans up file repos that were moved to /pulp/isos/<org name>/" task :clean_old_file_repos => ['environment'] do User.current = User.anonymous_admin PUB_DIR = '/var/www/pub'.freeze SCRIPT_PATH = '/tmp/delete_old_file_repos.sh'.freeze delete = [] %w(http https).each do |proto| dir = "#{PUB_DIR}/#{proto}/isos/" if File.directory?(dir) Dir.foreach(dir) do |entry| # If directory is a file repo, then it was published using # the UUID. It's a target for deletion. if (repo = Katello::Repository.find_by(pulp_id: File.basename(entry))) && (repo.content_type == Katello::Repository::FILE_TYPE) delete << "#{dir}#{entry}" end end end end if delete.empty? puts "There are no directories to delete." else open(SCRIPT_PATH, 'w') { |f| f << "rm -rf #{delete.join " \\\n "}\n" } puts "To clean up the directories, please run the following as root:\n# bash #{SCRIPT_PATH}" end puts "Rake task completed." end end
Version data entries
15 entries across 15 versions & 1 rubygems