#!/usr/bin/env python # Script to download and install new yum repo files easily # (C) 2010 Kushal Das # This script is licensed under the # GNU General Public License, # version 2 or any later version. import urllib2 import sys import os def main(argv): try: site = argv[1] fas = argv[2] name = argv[3] except: print "Usage: yum-add-repo sitename fasname reponame" return url = "http://%s.%s.org/%s.repo" % (fas,site, name) try: f = urllib2.urlopen(url) html = f.read() f.close() except: print "Can not find the repo with url %s" % url return print "Found the repo file" print "" print html while True: ip = raw_input("Do you want to install it [y/N]: ") if ip in ['n','N']: return elif ip == 'y': if os.geteuid() != 0: print "Please run this tool as root to install a repo" return try: f = open('/etc/yum.repos.d/%s.repo' % name, "w") f.write(html) f.close() except: print "Problem installing the repo" return else: continue if __name__ == '__main__': main(sys.argv)