def doScript(section, script, scriptnum):
fname = '/run/ks-script-%s-%d' % (section, scriptnum)
f = open(fname, 'w')
f.write('#!%s\n\n' % script.interp)
s = '%s' % script
for line in s.split('\n'):
if line.startswith('%pre') or line.startswith('%post') \
or line.startswith('%end'):
#
# skip
#
continue
f.write('%s\n' % line)
f.close()
os.chmod(fname, 0700)
pid = os.fork()
if pid == 0:
if section == 'post' and script.inChroot:
shutil.copy(fname, '/run/mnt/sysimage%s' % fname)
os.chroot('/run/mnt/sysimage')
#
# set stdout and stderr to files on the disk so we can examine
# the output and errors
#
fout = open('%s.out' % fname, 'w')
ferr = open('%s.err' % fname, 'w')
subprocess.call([ fname ], stdout = fout, stderr = ferr)
fout.close()
ferr.close()
sys.exit(0)
else:
os.wait()
评论列表
文章目录