diff --git a/xCAT-server-2.0/sbin/updateSNimage b/xCAT-server-2.0/sbin/updateSNimage index 9a5de3d43..5790e3c8d 100644 --- a/xCAT-server-2.0/sbin/updateSNimage +++ b/xCAT-server-2.0/sbin/updateSNimage @@ -24,7 +24,7 @@ use File::Copy; This routine updates the service node diskless install image with the extra files it needs to support running the postgresql and xcatd - daemon on the service node. + daemon on the service node. If also creates a new fstab in the install image. Arguments: -n host ipaddress or name that can be used to scp, or blank for local host @@ -55,6 +55,8 @@ my $rc = 0; my $hostname; my $path; my $cpy; +my $cmd; + @hostpath = &getarg(); $path = pop @hostpath; my $hostname = pop @hostpath; @@ -68,14 +70,14 @@ if ($thostname eq "local") else { $cpy = "scp"; - $hostname .= ":"; + $hostname .= ":"; } # check to see /etc/xcat/ca and /etc/xcat/cert directory exist # if not make them if ($thostname eq "local") -{ # local host +{ # local host $cmd = "ls $path/etc/xcat/ca"; } else @@ -86,7 +88,7 @@ my @output = xCAT::Utils->runcmd($cmd, -1); if ($::RUNCMD_RC != 0) { if ($thostname eq "local") - { # local host + { # local host $cmd = "mkdir $path/etc/xcat/ca"; } else @@ -150,8 +152,10 @@ if ($::RUNCMD_RC != 0) } } my $path1 = "$path/"; + # build each copy command my $path1 = "$path/"; + # build each copy command # cp -p /etc/sysconfig/xcat $path/etc/sysconfig/xcat , if local or # scp -p /etc/sysconfig/xcat $hostname:$path/etc/sysconfig/xcat if remote @@ -231,6 +235,10 @@ foreach $cmd (@cmd) } } +# create a new fstab + +$rc = &create_fstab($path); + exit $rc; #----------------------------------------------------------------------------- @@ -308,7 +316,7 @@ sub getarg sub usage { my $usage; - my $usage1 = " upadteSNimage -h \n updateSNimage -v \n "; + my $usage1 = " updateSNimage -h \n updateSNimage -v \n "; my $usage2 = "updateSNimage {-n hostname | hostip } [-p path to image] \n "; my $usage3 = " -n hostname or ipadress where image is located \n "; @@ -319,3 +327,52 @@ sub usage xCAT::MsgUtils->message("I", $usage); return 0; } + +#----------------------------------------------------------------------------- + +=head2 create_fstab + + Saves old fstab and creates a new one, if not already done + +=cut + +#----------------------------------------------------------------------------- + +sub create_fstab +{ + my ($path) = @_; + my $cmd; + my $file = "$path/etc/fstab"; + my $file2 = "$path/etc/fstab.ORIG"; + if (!(-e $file2)) + { # if not already done + $cmd = "cp -p $file $file2"; + my @output = xCAT::Utils->runcmd($cmd, 0); + if ($::RUNCMD_RC != 0) + { + xCAT::MsgUtils->message("E", "Error from $cmd, @output"); + return 1; + } + + # build the fstab file + my @fstabtemplate; + $fstabtemplate[0] = "proc /proc proc rw 0 0\n"; + $fstabtemplate[1] = "sysfs /sys sysfs rw 0 0\n"; + $fstabtemplate[2] = + "devpts /dev/pts devpts rw,gid=5,mode=620 0 0\n"; + $fstabtemplate[3] = "#tmpfs /dev/shm tmpfs rw 0 0\n"; + $fstabtemplate[4] = "compute_x86_64 / tmpfs rw 0 1\n"; + $fstabtemplate[5] = + "none /tmp tmpfs defaults,size=10m 0 2\n"; + $fstabtemplate[6] = + "none /var/tmp tmpfs defaults,size=10m 0 2\n"; + + open(FSTABCFG, ">$file") + or + xCAT::MsgUtils->message('S', "Cannot open $file for fstab setup. \n"); + print FSTABCFG @fstabtemplate; + close FSTABCFG; + } + return 0; +} +