Certain system services are now started with the SLES12 operating system, to keep backwards compatiability, check if the service is in etc/init.d in the rootimg and only run inssrv on those.

Smarter code added for loading kernel modules
This commit is contained in:
Victor Hu 2015-01-20 16:38:08 -05:00
parent 2436fee9c8
commit 5549d2e033

View File

@ -855,7 +855,13 @@ if (@new_order) {
}
# add drivers for local disk support
push @ndrivers, ("ext3.ko", "ext4.ko", "virtio_pci.ko", "virtio_blk.ko", "ata_piix.ko", "libata.ko", "scsi_mod.ko", "scsi_dh.ko", "ahci.ko", "ibmvscsi.ko", "ibmvscsic.ko", "megaraid_sas.ko", "pcieport.ko", "sd_mod.ko");
push @ndrivers, ("ext3.ko", "ext4.ko", "virtio_pci.ko", "virtio_blk.ko", "libata.ko", "scsi_mod.ko", "scsi_dh.ko", "ahci.ko", "megaraid_sas.ko", "sd_mod.ko");
if ($osver_host >= 12) {
push @ndrivers, ("ibmvscsi.ko");
} else { # for sles11 or lower
push @ndrivers, ("ibmvscsic.ko", "ata_piix.ko", "pcieport.ko");
}
if (-f "$rootimg_dir/lib/modules/$kernelver/kernel/drivers/net/ethernet/mellanox/mlx4/mlx4_en.ko") {
for (@ndrivers) {
@ -1963,18 +1969,42 @@ sub generic_post { # This function is meant to leave the image in a state approx
copy("$installroot/postscripts/xcatpostinit", "$rootimg_dir/etc/init.d/xcatpostinit");
chmod(0755, "$rootimg_dir/etc/init.d/xcatpostinit");
#insserv with -f option to ignore the dependency on sles10.4
system("chroot $rootimg_dir insserv -f network sshd gettyset xcatpostinit");
my $rc = system("grep sshd $rootimg_dir/etc/init.d/.depend.start | grep TARGETS");
if ($rc) {
system("sed -i '".'s/^\(TARGETS = .*\)$/\1 sshd/'."' $rootimg_dir/etc/init.d/.depend.start");
system("ln -s ../sshd $rootimg_dir/etc/init.d/rc3.d/S20sshd");
#
# set certain system services to start on boot, if the file exists in /etc/init.d as a script,
# use insserv to start it. If not, assume that the service is controlled by systemctl
#
# note: insserv is passed the -f option to ignore the dependency on sles10.4
#
print "[genimage] setting services to start at boot time...\n";
my @services;
push @services, qw/sshd network gettyset xcatpostinit/;
foreach my $service (@services) {
my $cmd = "chroot $rootimg_dir ";
if (-r "$rootimg_dir/etc/init.d/$service" ) {
$cmd = $cmd . "insserv -f $service";
system("$cmd");
}
else {
print "[genimage] Not starting service $service, verify if started by systemctl\n";
}
}
my $rc = system("grep gettyset $rootimg_dir/etc/init.d/.depend.start | grep TARGETS");
if ($rc) {
system("sed -i '".'s/^\(TARGETS = .*\)$/\1 gettyset/'."' $rootimg_dir/etc/init.d/.depend.start");
system("ln -s ../gettyset $rootimg_dir/etc/init.d/rc3.d/S60gettyset");
#
# Check if .depend.start file exists. For SLES12 and later OS, this does not apply
#
if (-r '$rootimg_dir/etc/init.d/.depend.start') {
my $rc = system("grep sshd $rootimg_dir/etc/init.d/.depend.start | grep TARGETS");
if ($rc) {
system("sed -i '".'s/^\(TARGETS = .*\)$/\1 sshd/'."' $rootimg_dir/etc/init.d/.depend.start");
system("ln -s ../sshd $rootimg_dir/etc/init.d/rc3.d/S20sshd");
}
my $rc = system("grep gettyset $rootimg_dir/etc/init.d/.depend.start | grep TARGETS");
if ($rc) {
system("sed -i '".'s/^\(TARGETS = .*\)$/\1 gettyset/'."' $rootimg_dir/etc/init.d/.depend.start");
system("ln -s ../gettyset $rootimg_dir/etc/init.d/rc3.d/S60gettyset");
}
}
}