diff --git a/xCAT-client-2.0/pods/man1/updte_SNimage.1.pod b/xCAT-client-2.0/pods/man1/updte_SNimage.1.pod new file mode 100644 index 000000000..cfb54fae8 --- /dev/null +++ b/xCAT-client-2.0/pods/man1/updte_SNimage.1.pod @@ -0,0 +1,64 @@ +=head1 NAME + +B - Adds the needed Service Node configuration files to the install image. + +=head1 SYNOPSIS + +I + +I + +I + +=head1 DESCRIPTION + +This command is used to add the Service Node configuration files to the install image. It will either copy them locally or scp them to a remote host. + +=head1 OPTIONS + + +B<-h |--help> Display usage message. + +B<-v |--version> Display xCAT version. + + +B<-n | --node> A remote host name or ip address that contains the install image to be updated. + + +B<-p |--path> Path to the install image. + + +=head1 RETURN VALUE + +0 The command completed successfully. + +1 An error has occurred. + +=head1 EXAMPLES + +1. To update the image on the local host. + +I + + +2. To update the image on a remote host. + +I + + +=head1 FILES + +$XCATROOT/bin/chdef + +(The XCATROOT environment variable is set when xCAT is installed. The +default value is "/opt/xcat".) + + +=head1 NOTES + +This command is part of the xCAT software product. +When going to a remote host, the command uses scp. It is best to have ssh keys setup so you will not be prompted for a password on each copy. + + + + diff --git a/xCAT-server-2.0/sbin/updte_SNimage b/xCAT-server-2.0/sbin/updte_SNimage new file mode 100644 index 000000000..81fcbfd56 --- /dev/null +++ b/xCAT-server-2.0/sbin/updte_SNimage @@ -0,0 +1,306 @@ +#!/usr/bin/perl +# IBM(c) 2007 EPL license http://www.eclipse.org/legal/epl-v10.html +#egan@us.ibm.com +#(C)IBM Corp + +# + +BEGIN +{ + $::XCATROOT = + $ENV{'XCATROOT'} ? $ENV{'XCATROOT'} + : -d '/opt/xcat' ? '/opt/xcat' + : '/usr'; +} +use lib "$::XCATROOT/lib/perl"; +use File::Basename; +use Getopt::Long; +use xCAT::MsgUtils; +use xCAT::Utils; +use File::Copy; + +#----------------------------------------------------------------------------- + +=head1 updte_SNimage + + 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. + + Arguments: + -n host ipaddress or name that can be used to scp, or blank for local host + -p full path to diskless image to update + -h help + -v version + + Returns: + 0 = success + 1 = error + Globals: + none + Error: + none + Example: + updte_SNimage -n -i + updte_SNimage -i + + Comments: + +=cut + +#----------------------------------------------------------------------------- +# Main + +my $rc = 0; + +my $hostname; +my $path; +my $cpy; +@hostpath = &getarg(); +$path = pop @hostpath; +my $hostname = pop @hostpath; +my $thostname = $hostname; +if ($thostname eq "local") +{ # local host + $cpy = "cp"; + $hostname = ""; # no hostname in the copy and use local cp + `unalias cp`; # remove prompting +} +else +{ + $cpy = "scp"; +} + +# check to see /etc/xcat/ca and /etc/xcat/cert directory exist +# if not make them + +if ($thostname eq "local") +{ # local host + $cmd = "ls $path/etc/xcat/ca"; +} +else +{ + $cmd = "ssh $hostname ls $path/etc/xcat/ca"; +} +my @output = xCAT::Utils->runcmd($cmd, -1); +if ($::RUNCMD_RC != 0) +{ + if ($thostname eq "local") + { # local host + $cmd = "mkdir $path/etc/xcat/ca"; + } + else + { + $cmd = "ssh $hostname mkdir $path/etc/xcat/ca"; + } + my @output = xCAT::Utils->runcmd($cmd, 0); + if ($::RUNCMD_RC != 0) + { + xCAT::MsgUtils->message("E", "Error from $cmd, @output"); + } +} +if ($thostname eq "local") +{ # local host + $cmd = "ls $path/etc/xcat/cert"; +} +else +{ + $cmd = "ssh $hostname ls $path/etc/xcat/cert"; +} +my @output = xCAT::Utils->runcmd($cmd, -1); +if ($::RUNCMD_RC != 0) +{ + if ($thostname eq "local") + { # local host + $cmd = "mkdir $path/etc/xcat/cert"; + } + else + { + $cmd = "ssh $hostname mkdir $path/etc/xcat/cert"; + } + my @output = xCAT::Utils->runcmd($cmd, 0); + if ($::RUNCMD_RC != 0) + { + xCAT::MsgUtils->message("E", "Error from $cmd, @output"); + } +} +my $path1 = "$path/"; +$hostname .= ":"; + +# 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 +my $filename = " /etc/sysconfig/xcat "; +my $filename2 = "etc/sysconfig/xcat "; +my $copy1 = $cpy; +$copy1 .= " -p "; +$copy1 .= $filename; +$copy1 .= $hostname; +$copy1 .= $path1; +$copy1 .= $filename2; + +# cp -p /etc/xcat/cfgloc $path/etc/xcat/cfgloc , if local or +# scp -p /etc/xcat/cfgloc $hostname:$path/etc/xcat/cfgloc if remote +$filename = " /etc/xcat/cfgloc "; +$filename2 = "etc/xcat/cfgloc "; +my $copy2 = $cpy; +$copy2 .= " -p "; +$copy2 .= $filename; +$copy2 .= $hostname; +$copy2 .= $path1; +$copy2 .= $filename2; + +# cp -p /root/.xcat/* $path/root/.xcat/. , if local or +# scp -p /root/.xcat/* $hostname:$path/root/.xcat/. if remote +$filename = " /root/.xcat/* "; +$filename2 = "root/.xcat/. "; +my $copy3 = $cpy; +$copy3 .= " -p "; +$copy3 .= $filename; +$copy3 .= $hostname; +$copy3 .= $path1; +$copy3 .= $filename2; + +# cp -p /etc/syslog $path/etc/syslog , if local or +# scp -p /etc/syslog $hostname:$path/etc/syslog if remote +$filename = " /etc/syslog.conf "; +$filename2 = "etc/syslog.conf "; +my $copy4 = $cpy; +$copy4 .= " -p "; +$copy4 .= $filename; +$copy4 .= $hostname; +$copy4 .= $path1; +$copy4 .= $filename2; + +# cp -rp /etc/xcat/ca/* $path/etc/xcat/ca/. , if local or +# scp -rp /etc/xcat/ca/* $hostname:$path/etc/xcat/ca/. if remote +$filename = " /etc/xcat/ca/* "; +$filename2 = "etc/xcat/ca/. "; +my $copy5 = $cpy; +$copy5 .= " -rp "; +$copy5 .= $filename; +$copy5 .= $hostname; +$copy5 .= $path1; +$copy5 .= $filename2; + +# cp -p /etc/xcat/cert/* $path/etc/xcat/cert/. , if local or +# scp -p /etc/xcat/cert/* $hostname:$path/etc/xcat/cert/. if remote +$filename = " /etc/xcat/cert/* "; +$filename2 = "etc/xcat/cert/. "; +my $copy6 = $cpy; +$copy6 .= " -p "; +$copy6 .= $filename; +$copy6 .= $hostname; +$copy6 .= $path1; +$copy6 .= $filename2; + +# cp -p /etc/profile.d/xcatsn.sh $path/etc/profile.d/xcatsn.sh , if local or +# scp -p /etc/profile.d/xcatsn.sh $hostname:$path/etc/profile.d/xcatsn.sh if remote +$filename = " /etc/profile.d/xcatsn.sh "; +$filename2 = "etc/profile.d/xcatsn.sh "; +my $copy7 = $cpy; +$copy7 .= " -p "; +$copy7 .= $filename; +$copy7 .= $hostname; +$copy7 .= $path1; +$copy7 .= $filename2; +my @cmd = ($copy1, $copy2, $copy3, $copy4, $copy5, $copy6, $copy7); + +foreach $cmd (@cmd) +{ + + my @output = xCAT::Utils->runcmd($cmd, 0); + if ($::RUNCMD_RC != 0) + { + xCAT::MsgUtils->message("E", "Error from $cmd, @output"); + } +} + +exit $rc; + +#----------------------------------------------------------------------------- + +=head2 getarg + + parses input + +=cut + +#----------------------------------------------------------------------------- + +sub getarg +{ + + Getopt::Long::Configure("posix_default"); + Getopt::Long::Configure("no_gnu_compat"); + Getopt::Long::Configure("bundling"); + my @output; + my %options = (); + + if ( + !GetOptions( + 'h|help' => \$options{'help'}, + 'n|node=s' => \$options{'node'}, + 'p|path=s' => \$options{'path'}, + 'v|version' => \$options{'version'} + + ) + ) + { + + &usage; + exit 1; + } + if ($options{'help'}) + { + &usage; + exit 0; + } + if ($options{'version'}) + { + xCAT::MsgUtils->message("I", "Version 2.0\n"); + exit 0; + } + + # must input hostname and path + if (!($options{'path'})) # required + { + xCAT::MsgUtils->message("E", "-p path to image is required\n"); + exit 1; + } + if ($options{'node'}) + { + push @output, $options{'node'}; + } + else + { + push @output, "local"; + } + push @output, $options{'path'}; + + return @output; +} + +#----------------------------------------------------------------------------- + +=head2 usage + + displays usages message + +=cut + +#----------------------------------------------------------------------------- +sub usage +{ + my $usage; + my $usage1 = " updte_SNimage -h \n updte_SNimage -v \n "; + my $usage2 = "updte_SNimage {-n hostname | hostip } [-p path to image] \n "; + my $usage3 = + " -n hostname or ipadress where image is located \n "; + " if not input copies to local host. \n "; + my $usage4 = " -p full path to image to update with \n "; + my $usage5 = " service node files. \n "; + $usage .= $usage1 .= $usage2 .= $usage3 .= $usage4 .= $usage5; + xCAT::MsgUtils->message("I", $usage); + return 0; +} diff --git a/xCATsn/xCATsn.spec b/xCATsn/xCATsn.spec index bb74e7138..70eed2867 100644 --- a/xCATsn/xCATsn.spec +++ b/xCATsn/xCATsn.spec @@ -51,7 +51,7 @@ if [ "$1" = "1" ]; then #Only if installing for the first time.. echo '/tftpboot *(ro,root_squash,sync)' >> /etc/exports #SECURITY: this has potential for sharing private host/user keys fi if ! grep /install /etc/exports; then - echo '/install *(ro,no_root_squash,sync)' >> /etc/exports #SECURITY: this has potential for sharing private host/user keys + echo '/install *(rw,no_root_squash,sync)' >> /etc/exports #SECURITY: this has potential for sharing private host/user keys fi chkconfig nfs on /etc/rc.d/init.d/nfs stop