mirror of
https://github.com/xcat2/xcat-core.git
synced 2025-05-22 11:42:05 +00:00
fix issue netboot postscripts have no knowledge about the osimage it is installing. #1857; export osimage attributes to postinstall scripts as environment variables
This commit is contained in:
parent
4098416bdf
commit
66c99aad31
@ -92,8 +92,17 @@ linuximage Attributes:
|
||||
|
||||
\ **postinstall**\
|
||||
|
||||
The fully qualified name of the script file that will be run at the end of the genimage command. It could be set to multiple paths. The multiple paths must be separated by ",". It is used for diskless image only.
|
||||
|
||||
Only supported in diskless image only. The fully qualified name of the scripts running in non-chroot mode after the package installation but before initrd generation during genimage. If multiple scripts are specified, they should be speperated with comma ",". A set of osimage attributes are exported as the environment variables to be used in the postinstall scripts ::
|
||||
|
||||
IMG_ARCH(The architecture of the osimage, such as "ppc64le","x86_64"),
|
||||
IMG_OSVER(The os release of the osimage, such as "rhels7.3","sles11.4"),
|
||||
IMG_PROFILE(the profile of the osimage, such as "service","compute"),
|
||||
IMG_PKGLIST(the "pkglist" attribute of the osimage),
|
||||
IMG_PKGDIR(the "pkgdir" attribute of the osimage),
|
||||
IMG_OTHERPKGLIST(the "otherpkglist" attribute of the osimage),
|
||||
IMG_OTHERPKGDIR(the "otherpkgdir" attribute of the osimage),
|
||||
IMG_ROOTIMGDIR(the "rootimgdir" attribute of the osimage)
|
||||
|
||||
|
||||
|
||||
\ **rootimgdir**\
|
||||
|
@ -313,7 +313,16 @@ osimage Attributes:
|
||||
|
||||
\ **postinstall**\ (linuximage.postinstall)
|
||||
|
||||
The fully qualified name of the script file that will be run at the end of the genimage command. It could be set to multiple paths. The multiple paths must be separated by ",". It is used for diskless image only.
|
||||
Only supported in diskless image only. The fully qualified name of the scripts running in non-chroot mode after the package installation but before initrd generation during genimage. If multiple scripts are specified, they should be speperated with comma ",". A set of osimage attributes are exported as the environment variables to be used in the postinstall scripts ::
|
||||
|
||||
IMG_ARCH(The architecture of the osimage, such as "ppc64le","x86_64"),
|
||||
IMG_OSVER(The os release of the osimage, such as "rhels7.3","sles11.4"),
|
||||
IMG_PROFILE(the profile of the osimage, such as "service","compute"),
|
||||
IMG_PKGLIST(the "pkglist" attribute of the osimage),
|
||||
IMG_PKGDIR(the "pkgdir" attribute of the osimage),
|
||||
IMG_OTHERPKGLIST(the "otherpkglist" attribute of the osimage),
|
||||
IMG_OTHERPKGDIR(the "otherpkgdir" attribute of the osimage),
|
||||
IMG_ROOTIMGDIR(the "rootimgdir" attribute of the osimage)
|
||||
|
||||
|
||||
|
||||
|
@ -773,7 +773,15 @@ passed as argument rather than by table value',
|
||||
otherpkglist => 'The fully qualified name of the file that stores non-distro package lists that will be included in the image. It could be set to multiple paths. The multiple paths must be separated by ",".',
|
||||
otherpkgdir => 'The base directory where the non-distro packages are stored. Only 1 local directory supported at present.',
|
||||
exlist => 'The fully qualified name of the file that stores the file names and directory names that will be excluded from the image during packimage command. It is used for diskless image only.',
|
||||
postinstall => 'The fully qualified name of the script file that will be run at the end of the genimage command. It could be set to multiple paths. The multiple paths must be separated by ",". It is used for diskless image only.',
|
||||
postinstall => 'Only supported in diskless image only. The fully qualified name of the scripts running in non-chroot mode after the package installation but before initrd generation during genimage. If multiple scripts are specified, they should be speperated with comma ",". A set of osimage attributes are exported as the environment variables to be used in the postinstall scripts:
|
||||
IMG_ARCH(The architecture of the osimage, such as "ppc64le","x86_64"),
|
||||
IMG_OSVER(The os release of the osimage, such as "rhels7.3","sles11.4"),
|
||||
IMG_PROFILE(the profile of the osimage, such as "service","compute"),
|
||||
IMG_PKGLIST(the "pkglist" attribute of the osimage),
|
||||
IMG_PKGDIR(the "pkgdir" attribute of the osimage),
|
||||
IMG_OTHERPKGLIST(the "otherpkglist" attribute of the osimage),
|
||||
IMG_OTHERPKGDIR(the "otherpkgdir" attribute of the osimage),
|
||||
IMG_ROOTIMGDIR(the "rootimgdir" attribute of the osimage)',
|
||||
rootimgdir => 'The directory name where the image is stored. It is generally used for diskless image. it also can be used in sysclone environment to specify where the image captured from golden client is stored. in sysclone environment, rootimgdir is generally assigned to some default value by xcat, but you can specify your own store directory. just one thing need to be noticed, wherever you save the image, the name of last level directory must be the name of image. for example, if your image name is testimage and you want to save this image under home directoy, rootimgdir should be assigned to value /home/testimage/',
|
||||
kerneldir => 'The directory name where the 3rd-party kernel is stored. It is used for diskless image only.',
|
||||
nodebootif => 'The network interface the stateless/statelite node will boot over (e.g. eth0)',
|
||||
|
@ -737,11 +737,23 @@ EOS_UNAME
|
||||
|
||||
$updates{'postinstall'} = $postinstall_filename if ($tempfile);
|
||||
|
||||
#export some osimage attributes as the environment variables
|
||||
#to postinstall script
|
||||
$ENV{IMG_ARCH}=$arch if("" ne $arch);
|
||||
$ENV{IMG_OSVER}=$osver if("" ne $osver);
|
||||
$ENV{IMG_PROFILE}=$profile if("" ne $profile);
|
||||
$ENV{IMG_PKGLIST}=$pkglist if("" ne $pkglist);
|
||||
$ENV{IMG_PKGDIR}=$srcdir if("" ne $srcdir);
|
||||
$ENV{IMG_OTHERPKGLIST}=$otherpkglist if("" ne $otherpkglist);
|
||||
$ENV{IMG_OTHERPKGDIR}=$srcdir_otherpkgs if("" ne $srcdir_otherpkgs);
|
||||
$ENV{IMG_ROOTIMGDIR}=$rootimg_dir if("" ne $rootimg_dir);
|
||||
|
||||
foreach my $postinstall (split /,/, $postinstall_filename) {
|
||||
if (!-x $postinstall) {
|
||||
print "postinstall script $postinstall is not executable\n";
|
||||
exit 1;
|
||||
}
|
||||
|
||||
my $rc = system($postinstall, $rootimg_dir, $osver, $arch, $profile);
|
||||
if ($rc) {
|
||||
print "postinstall script $postinstall failed\n";
|
||||
@ -749,6 +761,9 @@ EOS_UNAME
|
||||
}
|
||||
}
|
||||
|
||||
#delete the osimage attributes from environment variable
|
||||
delete @ENV{qw(IMG_ARCH IMG_OSVER IMG_PROFILE IMG_PKGLIST IMG_PKGDIR IMG_OTHERPKGLIST IMG_OTHERPKGDIR IMG_ROOTIMGDIR)};
|
||||
|
||||
# restore the orig uname
|
||||
system("mv $rootimg_dir/bin/orig_uname $rootimg_dir/bin/uname");
|
||||
|
||||
|
@ -724,6 +724,17 @@ EOS_UNAME
|
||||
|
||||
$updates{'postinstall'} = $postinstall_filename if ($tempfile);
|
||||
|
||||
#export some osimage attributes as the environment variables
|
||||
#to postinstall script
|
||||
$ENV{IMG_ARCH}=$arch if("" ne $arch);
|
||||
$ENV{IMG_OSVER}=$osver if("" ne $osver);
|
||||
$ENV{IMG_PROFILE}=$profile if("" ne $profile);
|
||||
$ENV{IMG_PKGLIST}=$pkglist if("" ne $pkglist);
|
||||
$ENV{IMG_PKGDIR}=$srcdir if("" ne $srcdir);
|
||||
$ENV{IMG_OTHERPKGLIST}=$otherpkglist if("" ne $otherpkglist);
|
||||
$ENV{IMG_OTHERPKGDIR}=$srcdir_otherpkgs if("" ne $srcdir_otherpkgs);
|
||||
$ENV{IMG_ROOTIMGDIR}=$rootimg_dir if("" ne $rootimg_dir);
|
||||
|
||||
foreach my $postinstall (split /,/, $postinstall_filename) {
|
||||
if (!-x $postinstall) {
|
||||
print "postinstall script $postinstall is not executable\n";
|
||||
@ -736,6 +747,8 @@ EOS_UNAME
|
||||
}
|
||||
}
|
||||
|
||||
#delete the osimage attributes from environment variable
|
||||
delete @ENV{qw(IMG_ARCH IMG_OSVER IMG_PROFILE IMG_PKGLIST IMG_PKGDIR IMG_OTHERPKGLIST IMG_OTHERPKGDIR IMG_ROOTIMGDIR)};
|
||||
|
||||
# restore the orig uname
|
||||
system("mv $rootimg_dir/bin/orig_uname $rootimg_dir/bin/uname");
|
||||
|
@ -617,6 +617,17 @@ if ($postinstall_filename) {
|
||||
|
||||
$updates{'postinstall'} = $postinstall_filename if ($tempfile);
|
||||
|
||||
#export some osimage attributes as the environment variables
|
||||
#to postinstall script
|
||||
$ENV{IMG_ARCH}=$arch if("" ne $arch);
|
||||
$ENV{IMG_OSVER}=$osver if("" ne $osver);
|
||||
$ENV{IMG_PROFILE}=$profile if("" ne $profile);
|
||||
$ENV{IMG_PKGLIST}=$pkglist if("" ne $pkglist);
|
||||
$ENV{IMG_PKGDIR}=$srcdir if("" ne $srcdir);
|
||||
$ENV{IMG_OTHERPKGLIST}=$otherpkglist if("" ne $otherpkglist);
|
||||
$ENV{IMG_OTHERPKGDIR}=$srcdir_otherpkgs if("" ne $srcdir_otherpkgs);
|
||||
$ENV{IMG_ROOTIMGDIR}=$rootimg_dir if("" ne $rootimg_dir);
|
||||
|
||||
foreach my $postinstall (split /,/, $postinstall_filename) {
|
||||
if (!-x $postinstall) {
|
||||
print "postinstall script $postinstall is not executable\n";
|
||||
@ -628,6 +639,10 @@ if ($postinstall_filename) {
|
||||
exit 1;
|
||||
}
|
||||
}
|
||||
|
||||
#delete the osimage attributes from environment variable
|
||||
delete @ENV{qw(IMG_ARCH IMG_OSVER IMG_PROFILE IMG_PKGLIST IMG_PKGDIR IMG_OTHERPKGLIST IMG_OTHERPKGDIR IMG_ROOTIMGDIR)};
|
||||
|
||||
}
|
||||
|
||||
# Default to the first kernel found in the install image if nothing specified explicitly.
|
||||
|
Loading…
x
Reference in New Issue
Block a user