Chinaunix

标题: kickstart的安装后脚本 [打印本页]

作者: 小谦    时间: 2008-04-18 11:08
标题: kickstart的安装后脚本
我在kickstart 文件中填入了安装后的python脚本,系统安装完后执行脚本时出错。手动重启系统,然后把python脚本拷出来单独执行,可以成功运行。
我想问安装完系统后,在系统重启以前,网卡配置好了吗?(两块网卡,生成kickstart文件的时候指定启动2个网卡)
还有是,kickstart的安装完后的脚本,环境变量啥的是不是都不能用呢?执行脚本时的用户权限又是什么?

谢谢~
作者: 小谦    时间: 2008-04-18 13:05
kickstart文件中的python脚本部分:
%post  --interp python
#!/usr/bin/env python
#coding=utf-8
#Auto install Globus and software it dependent
#File:globusinstall.py

import os
from subprocess import *

call(['/usr/bin/yum', '-y', 'install', 'perl-XML-Parser'])

#The three packages: apache-ant-1.7.0-bin.tar.gz、jdk-6u2-linux-i586-rpm.bin、
#gt4.0.5-all-source-installer.tar.gz are put on /root/

call(['/bin/mount', '192.168.187.140:/grid', '/mnt'])
call(['/bin/cp', '/mnt/jdk-6u2-linux-i586-rpm.bin', '/root/jdk-6u2-linux-i586-rpm.bin'])
call(['/bin/cp', '/mnt/apache-ant-1.7.0-bin.tar.gz', '/root/apache-ant-1.7.0-bin.tar.gz'])
call(['/bin/cp', '/mnt/gt4.0.5-all-source-installer.tar.gz', '/root/gt4.0.5-all-source-installer.tar.gz'])


#install jdk
os.chdir('/root')
call(['/bin/chmod', '+x', 'jdk-6u2-linux-i586-rpm.bin'])
call(['/bin/cp', 'jdk-6u2-linux-i586-rpm.bin', '/usr/local'])








提示错误:

作者: 小谦    时间: 2008-04-19 10:18
弄了2天了,还找不出哪里错误来~
同志们帮我看看,谢谢~

下面是完整的ks.cfg文件,不知道哪里错了

#platform=x86, AMD64, 或 Intel EM64T
# System authorization information
auth  --useshadow  --enablemd5
# System bootloader configuration
bootloader --location=mbr
# Clear the Master Boot Record
zerombr
# Partition clearing information
clearpart --all --initlabel
# Use text mode install
text
# Firewall configuration
firewall --disabled
# Run the Setup Agent on first boot
firstboot --disable
# System keyboard
keyboard us
# System language
lang zh_CN
# Installation logging level
logging --level=info
# Use NFS installation media
nfs --server=192.168.187.140 --dir=/centos/
# Network information
network --bootproto=dhcp --device=eth0 --onboot=on
network --bootproto=dhcp --device=eth1 --onboot=on
# Reboot after installation
reboot
#Root password
rootpw  stugrid

# SELinux configuration
selinux --disabled
# System timezone
timezone  Asia/Shanghai
# Install OS instead of upgrade
install
# X Window System configuration information

xconfig  --defaultdesktop=GNOME --depth=32 --resolution=800x600 --startxonboot

%post  --interp python --nochroot
#!/usr/bin/env python
#coding=utf-8
#Auto install Globus and software it dependent
#File:globusinstall.py

import os
from subprocess import *

call(['/usr/bin/yum', '-y', 'install', 'perl-XML-Parser'])

#The three packages: apache-ant-1.7.0-bin.tar.gz、jdk-6u2-linux-i586-rpm.bin、
#gt4.0.5-all-source-installer.tar.gz are put on /root/

call(['/bin/mount', '192.168.187.140:/grid', '/mnt'])
call(['/bin/cp', '/mnt/jdk-6u2-linux-i586-rpm.bin', '/root/jdk-6u2-linux-i586-rpm.bin'])
call(['/bin/cp', '/mnt/apache-ant-1.7.0-bin.tar.gz', '/root/apache-ant-1.7.0-bin.tar.gz'])
call(['/bin/cp', '/mnt/gt4.0.5-all-source-installer.tar.gz', '/root/gt4.0.5-all-source-installer.tar.gz'])


#install jdk
os.chdir('/root')
call(['/bin/chmod', '+x', 'jdk-6u2-linux-i586-rpm.bin'])
call(['/bin/cp', 'jdk-6u2-linux-i586-rpm.bin', '/usr/local'])

os.chdir('/usr/local')
logFile = file("./install.log", "w")
subProc = Popen(["./jdk-6u2-linux-i586-rpm.bin"], stdin = PIPE, stdout = logFile)
subProc.communicate("y")


%packages
@server-cfg
@base-x
@legacy-software-development
@gnome-desktop
@base
@x-software-development
@network-server
@kde-software-development
@development-libs
@java
@web-server
@mysql
@admin-tools
@gnome-software-development
@development-tools
@kde-desktop
@legacy-software-support
@sql-server
@java-development
@emacs
@graphical-internet
@graphics
@text-internet
@system-tools
@ftp-server
@smb-server
@editors
@ruby
@engineering-and-scientific
@dns-server
作者: 小谦    时间: 2008-04-19 19:31
有人这么回复,大家帮忙看看什么意思:
You need to chroot into the new install to correctly run the script, right now you are running it within the install environment

我试了,chroot选和不选都会有错。请问要怎么改正呢?怎样能使安装后脚本的运行根目录就是 / 呢?

[ 本帖最后由 小谦 于 2008-4-19 19:45 编辑 ]
作者: bl520025    时间: 2014-02-20 14:37
%post  --nochroot
脚本运行在当前的linux系统中
touch /root/test.file    安装完成后新系统的root下面没有test.file文件。
%post
脚本运行在新安装的操作系统中
touch /root/test.file    安装完成后新系统的root下面有test.file文件。




欢迎光临 Chinaunix (http://bbs.chinaunix.net/) Powered by Discuz! X3.2