User: user57  
  Date: 01/08/31 17:25:30

  Added:       src/bin  catchlog.sh nightly-website.sh update-website.sh
  Log:
   o adding scripts and helper scripts to run the nightly website update
  
  Revision  Changes    Path
  1.1                  newsite/src/bin/catchlog.sh
  
  Index: catchlog.sh
  ===================================================================
  #!/bin/sh
  ### ====================================================================== ###
  ##                                                                          ##
  ##  This script executes a child process and catches all output into a      ##
  ##  log file.                                                               ##
  ##                                                                          ##
  ### ====================================================================== ###
  
  # $Id: catchlog.sh,v 1.1 2001/09/01 00:25:30 user57 Exp $
  
  PROGNAME=`basename $0`
  DIRNAME=`dirname $0`
  CAT='cat'
  TEE='tee'
  
  ##
  ## Print an informative message
  ##
  info() {
      echo "${PROGNAME}: $*"
  }
  
  ##
  ## Print an error message and exit
  ##
  die() {
      info $*
      exit 1
  }
  
  ##
  ## Show command line help
  ## 
  show_help() {
      $CAT <<EOF
  usage: $PROGNAME [options] [--] <program to execute>
  
  options:
      --logfile, -l <logfile>    The file where output will be stored
      --append, -a               Append to the log file
      --quiet, -q                Try to be quite
      --help, -h                 Show this help message
      --                         Stop processing options
  EOF
  }
  
  ##
  ## Where all the fun stuff happens
  ##
  main() {
      # the list of arguments to execute
      args=""
  
      # the file to catch output to
      logfile="output.log"
  
      # a flag to append to the file
      append=""
  
      # a flag to tell us to be quiet
      quiet=""
  
      if [ "x$1" = "x" ]; then
        show_help
        exit
      fi
  
      # parse the command line
      while [ "x$1" != "x" ]; do
        case "$1" in
            --logfile|-l)
                if [ "x$2" = "x" ]; then
                    die "--logfile requires an additional argument"
                fi
                
                logfile="$2"
                shift
            ;;
  
            --append|-a)
                append="-a" # set for TEE
            ;;
  
            --quiet|-q)
                quiet="true"
            ;;
  
            --help|-h)
                show_help
                exit
            ;;
  
            --)
                shift
                if [ "x$args" = "x" ]; then
                    args="$*"
                else
                    args="$args $*"
                fi
                break
            ;;
  
            *)
                if [ "x$args" = "x" ]; then
                    args="$1"
                else
                    args="$args $1"
                fi
            ;;
        esac
        shift
      done
  
      # setup the log file
      if [ "x$append" = "x" ]; then
        if [ -e "$logfile" ]; then
            rm $logfile
        fi
      fi
      if [ ! -f "$logfile" ]; then
        touch $logfile
      fi
  
      # execute the program
      if [ "x$quiet" = "x" ]; then
        # use tee and let output display to the console
        $args | $TEE $append $logfile 2>&1
      else
        # append all output to the log, nothing goes to console
        $args >> $logfile 2>&1
      fi
  
      info "Log saved to $logfile"
  }
  
  ##
  ## Bootstrap
  ##
  main "$@"
  
  
  
  1.1                  newsite/src/bin/nightly-website.sh
  
  Index: nightly-website.sh
  ===================================================================
  #!/bin/sh
  ### ====================================================================== ###
  ##                                                                          ##
  ##  This script controlls the nighly update of the website.                 ##
  ##                                                                          ##
  ### ====================================================================== ###
  
  # $Id: nightly-website.sh,v 1.1 2001/09/01 00:25:30 user57 Exp $
  
  PROGNAME=`basename $0`
  DIRNAME=`dirname $0`
  
  # Setup Mail
  MAIL="mail"
  MAILTO="[EMAIL PROTECTED]" # change to [EMAIL PROTECTED] when done testing
  
  # Where the required scripts live
  SCRIPTROOT="$DIRNAME"
  
  # A date stamp
  DSTAMP=`date +%m%d%Y`
  
  # Where the logs will go
  LOGROOT="$HOME/log"
  LOGFILE="$LOGROOT/nightly-website.log"
  
  # Run the update-website.sh script.  It must be wrapped with catchlog.sh, 
  # because it uses the log file to determine build successes from it
  
  $SCRIPTROOT/catchlog.sh --logfile $LOGFILE -- \
      $SCRIPTROOT/update-website.sh $LOGFILE
  
  # Send out email about the update
  $MAIL $MAILTO -s "Website updated successfully" < $LOGFILE
  
  
  
  1.1                  newsite/src/bin/update-website.sh
  
  Index: update-website.sh
  ===================================================================
  #!/bin/sh
  ### ====================================================================== ###
  ##                                                                          ##
  ##  This script will update the jboss.org website from the jboss-website    ##
  ##  module pulled from CVS.                                                 ##
  ##                                                                          ##
  ### ====================================================================== ###
  
  # $Id: update-website.sh,v 1.1 2001/09/01 00:25:30 user57 Exp $
  
  PROGNAME=`basename $0`
  DIRNAME=`dirname $0`
  GREP="grep"
  TAIL="tail"
  CUT="cut"
  
  # Setup Mail
  MAIL="mail"
  MAILTO="[EMAIL PROTECTED]" # change to [EMAIL PROTECTED] when done testing
  
  # Setup CVS
  CVS="cvs"
  CVSROOT=":pserver:[EMAIL PROTECTED]:/cvsroot/jboss"
  CVS_OPTIONS="-z3 -d $CVSROOT"
  
  # Where we will will work from
  WORKDIR="$HOME/tmp/jboss/update-website"
  
  ##
  ## Print an informative message
  ##
  info() {
      echo "${PROGNAME}: $*"
  }
  
  ##
  ## Print an error message and exit
  ##
  die() {
      info $*
      exit 1
  }
  
  ##
  ## Mail out a log file to the MAILTO list
  ##
  maillog() {
      subject=$1
      logfile=$2
  
      $MAIL $MAILTO -s "$subject" < $logfile
  }
  
  ##
  ## Check the return status of child
  ##
  checkStatus() {
      have=$1
      want=$2
      message=$3
      logfile=$4
  
      info "Child exit status: $have"
  
      if [ "$have" != "$want" ]; then
        info "Unexpected child exit status; got $have, wanted $want"
        maillog "${PROGNAME}: $message" $logfile
        die $message
      fi
  }
  
  ##
  ## Check if a recient Ant build was successful
  ##
  checkBuild() {
      message=$1
      logfile=$2
  
      result=`$TAIL $logfile | $GREP BUILD | $CUT -f 2 -d " "`
      if [ "$result" != "SUCCESSFUL" ]; then
        maillog "${PROGNAME}: $message" $logfile
      fi
  }
  
  ##
  ## Where all the fun stuff happens
  ##
  main() {
      # check comamnd line options
      if [ "x$1" = "x" ]; then
        die "Must specify the name of the log file"
      fi
      logfile="$1"
      if [ `dirname $logfile` = "." ]; then
        logfile="`pwd`/$logfile"
      fi
  
      # check the log file
      if [ ! -e "$logfile" ]; then
        die "Log file does not exist, run with catchlog.sh"
      fi
  
      # setup the workdir, change to it
      info "Setting up WORKDIR: $WORKDIR"
      rm -rf $WORKDIR
      mkdir -p $WORKDIR
      cd $WORKDIR
  
      # pull down a fresh copy of jboss-website
      info "Pulling down a fresh copy of jboss-website"
      $CVS $CVS_OPTIONS get -AP jboss-website
      status=$?
      checkStatus $status 0 "cvs checkout failed" $logfile
  
      # enter the workspace dir so we can find tools correctly
      cd jboss-website
  
      # build the website
      info "Building website"
      ./build/build.sh website
      status=$?
      checkStatus $status 0 "build 'website' failed" $logfile
      checkBuild "build 'website' was not successful" $logfile
  
      # install the website
      info "Installing website"
      ./build/build.sh website-install
      status=$?
      checkStatus $status 0 "build 'website-install' failed" $logfile
      checkBuild "build 'website-install' was not successful" $logfile
  
      # Clean up and say goodbye
      info "Cleaning up WORKDIR"
      rm -rf $WORKDIR
  
      info "Done"
  }
  
  ##
  ## Bootstrap
  ##
  main "$@"
  
  
  

_______________________________________________
Jboss-development mailing list
[EMAIL PROTECTED]
http://lists.sourceforge.net/lists/listinfo/jboss-development

Reply via email to