From 64b86f4a67d7f6a41fdaab30e224f9d0cfd923b9 Mon Sep 17 00:00:00 2001 From: bp-sawyers Date: Thu, 3 Nov 2011 13:55:05 +0000 Subject: [PATCH] add upload option to getxcatdocs git-svn-id: https://svn.code.sf.net/p/xcat/code/xcat-core/trunk@10962 8638fb3e-16cb-4fca-ae20-7b5d299a9bcd --- xCAT-client/bin/getxcatdocs | 26 +++++++++++++++++++------- 1 file changed, 19 insertions(+), 7 deletions(-) diff --git a/xCAT-client/bin/getxcatdocs b/xCAT-client/bin/getxcatdocs index c6d6d4cf8..68031f18d 100755 --- a/xCAT-client/bin/getxcatdocs +++ b/xCAT-client/bin/getxcatdocs @@ -6,6 +6,9 @@ # that has internet access to run it. Before running this command, you must have # wget, python, and pisa installed. See: https://sourceforge.net/apps/mediawiki/xcat/index.php?title=Editing_xCAT_Documentation_Pages#Converting_Wiki_Pages_to_HTML_and_PDFs . +# Note: do not use the --upload option, unless your machine has authority to write to http://xcat.sourceforge.net/doc/ . +# You also need to set $UPLOADUSER to your sourceforge user. + #BEGIN #{ # $::XCATROOT = $ENV{'XCATROOT'} ? $ENV{'XCATROOT'} : -d '/opt/xcat' ? '/opt/xcat' : '/usr'; @@ -18,10 +21,11 @@ use Getopt::Long; #my $VERSION; my $HELP; +my $UPLOAD; my $usage = sub { my $exitcode = shift @_; - print "Usage: getxcatdocs [-?|-h|--help] []\n"; + print "Usage: getxcatdocs [-?|-h|--help] [-u|--upload] []\n"; exit $exitcode; }; @@ -29,7 +33,7 @@ my $usage = sub { Getopt::Long::Configure("bundling"); #Getopt::Long::Configure("pass_through"); Getopt::Long::Configure("no_pass_through"); -if (!GetOptions('h|?|help' => \$HELP )) { $usage->(1); } +if (!GetOptions('h|?|help' => \$HELP, 'u|upload' => \$UPLOAD )) { $usage->(1); } if ($HELP) { $usage->(0); } @@ -38,7 +42,6 @@ if ($HELP) { $usage->(0); } # exit; #} -#if (xCAT::Utils->isAIX()) { die "Error: this command is not yet supported on AIX.\n"; } if ($^O =~ /^aix/i) { die "Error: this command is not yet supported on AIX.\n"; } my $destdir = scalar(@ARGV) ? $ARGV[0] : '.'; @@ -69,14 +72,23 @@ foreach my $file (@dir) { #print "$cmd\n"; runh2p($cmd); } -# tar and compress + +# tar/compress chdir($docdir); my $date=`date +%Y%m%d%H%M`; chop $date; -my $docname="xcat-docs-snap$date.tar"; -`tar cvfj $docname html pdf`; -`gzip $docname`; +my $docname="xcat-docs-snap$date.tar.gz"; +system("tar -zcfz $docname html pdf 2>&1"); + +# Optionally upload the tarball to sourceforge +if ($UPLOAD) { + my $UPLOADUSER = 'bp-sawyers'; + my $count = 1; + while ($count<=5 && system("rsync -v $docname $UPLOADUSER," . 'xcat@web.sourceforge.net:htdocs/doc/ 2>&1')) { $count++; } +} exit 0; + + # Run the wget cmd and filter out some of the silly output sub runwget { my $cmd = shift;