我有一个ks脚本来安装Centos6.5。 在我的本地networking中,我有一个基础包镜像的快照。
我想尽可能使用,因为我可以通过外部网我的本地包网站,如http://mirrors.kernel.org/centos/6.5/os/x86_64/ 。
但是,ks脚本应该在本地networking之外工作,所以我需要定义一些后备/镜像url。
在Fedora环境中,有一个url指令的选项http://fedoraproject.org/wiki/Anaconda/Kickstart#url --mirrorlist但是它的选项对Centos6.5不存在。
有什么办法来解决我的问题?
我想过%pre bash脚本,但没有任何包,将很难testing哪个url我不得不select。
我会创build一个%pre Python脚本,并使用urllib2.urlopen()来检查您的本地存储库是否可用。 如果没有,它会使用在线镜像之一。
在这里看到示例用法: https : //stackoverflow.com/questions/16778435/python-check-if-website-exists
所以,例如:
%pre --interpreter=/usr/bin/python import urllib2 local_url = 'http://localserver/CentOS/6/os/' remote_url = 'http://mirror.zetup.net/CentOS/6/os/' # Determine which URL to use try: urllib2.urlopen(local_url) my_url = local_url except urllib2.URLError: my_url = remote_url # Write the .ks file with open('/tmp/install-url.ks', 'w') as f: f.write('url --url=' + my_url) %end # Network installation %include '/tmp/install-url.ks'