User: user57
Date: 01/08/31 19:20:53
Modified: src/bin catchlog.sh nightly-website.sh update-website.sh
Log:
o moved mailing upto nightly-website.sh
o catchlog.sh will return the exit status of its child
o status 2 means that the install failed, website could be down
Revision Changes Path
1.4 +7 -8 newsite/src/bin/catchlog.sh
Index: catchlog.sh
===================================================================
RCS file: /cvsroot/jboss/newsite/src/bin/catchlog.sh,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- catchlog.sh 2001/09/01 01:39:26 1.3
+++ catchlog.sh 2001/09/01 02:20:53 1.4
@@ -6,7 +6,7 @@
## ##
### ====================================================================== ###
-# $Id: catchlog.sh,v 1.3 2001/09/01 01:39:26 user57 Exp $
+# $Id: catchlog.sh,v 1.4 2001/09/01 02:20:53 user57 Exp $
PROGNAME=`basename $0`
DIRNAME=`dirname $0`
@@ -36,9 +36,9 @@
usage: $PROGNAME [options] [--] <program to execute>
options:
- --logfile, -l <logfile> The file where output will be stored
+ --logfile, -f <logfile> The file where output will be stored
--append, -a Append to the log file
- --quiet, -q Try to be quite
+ --quiet, -q Try to be quite [non-quiet uses $TEE]
--help, -h Show this help message
-- Stop processing options
EOF
@@ -68,7 +68,7 @@
# parse the command line
while [ "x$1" != "x" ]; do
case "$1" in
- --logfile|-l)
+ --logfile|-f)
if [ "x$2" = "x" ]; then
die "--logfile requires an additional argument"
fi
@@ -120,7 +120,7 @@
if [ ! -f "$logfile" ]; then
touch $logfile
fi
- echo "Opened log: `date`" >> $logfile
+ info "Opened log: `date`" >> $logfile
# execute the program
if [ "x$quiet" = "x" ]; then
@@ -132,11 +132,10 @@
$args >> $logfile 2>&1
status=$?
fi
- info "Exit status: $status"
+ info "Exit status: $status" >> $logfile
# try to get file to flush
- echo "Closing log: `date`" >> $logfile
- info "Log saved to $logfile"
+ info "Closing log: `date`" >> $logfile
exit $status
}
1.4 +68 -19 newsite/src/bin/nightly-website.sh
Index: nightly-website.sh
===================================================================
RCS file: /cvsroot/jboss/newsite/src/bin/nightly-website.sh,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- nightly-website.sh 2001/09/01 01:39:26 1.3
+++ nightly-website.sh 2001/09/01 02:20:53 1.4
@@ -5,7 +5,7 @@
## ##
### ====================================================================== ###
-# $Id: nightly-website.sh,v 1.3 2001/09/01 01:39:26 user57 Exp $
+# $Id: nightly-website.sh,v 1.4 2001/09/01 02:20:53 user57 Exp $
PROGNAME=`basename $0`
DIRNAME=`dirname $0`
@@ -13,28 +13,77 @@
# Where the required scripts live
SCRIPTROOT="$DIRNAME"
-# A date stamp
-DSTAMP=`date +%m%d%Y`
-
# Where the logs will go
LOGFILE="$HOME/log/nightly-website.log"
# Setup Mail
MAIL="mail"
MAILTO="[EMAIL PROTECTED]" # change to [EMAIL PROTECTED] when done testing
-
-# Setup CVS
-CVSROOT=":pserver:[EMAIL PROTECTED]:/cvsroot/jboss"
-export CVSROOT
-
-# 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 \
- --quiet \
- --logfile $LOGFILE \
- -- \
- $SCRIPTROOT/update-website.sh $LOGFILE
-status=$?
-echo "Exit status: $status"
+##
+## Print an informative message
+##
+info() {
+ echo "${PROGNAME}: $*"
+}
+
+##
+## Print an error message and exit
+##
+die() {
+ if [ "x$exitcode" = "x" ]; then
+ exitcode=1
+ fi
+ info $*
+ exit $exitcode
+}
+
+##
+## Mail out a log file to the MAILTO list
+##
+maillog() {
+ subject=$1
+ logfile=$2
+
+ $MAIL $MAILTO -s "$subject" < $logfile
+ info "Email notification sent to $MAILTO"
+}
+
+##
+## Where all the fun stuff happens
+##
+main() {
+ # 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 \
+ --quiet \
+ --logfile $LOGFILE \
+ -- \
+ $SCRIPTROOT/update-website.sh $LOGFILE
+ status=$?
+
+ case "$status" in
+ 0)
+ # everything is ok
+ true
+ ;;
+
+ 2)
+ # website might be down
+ info "Unexpected child exit status; got $status, wanted 0"
+ maillog "${PROGNAME}: failed to install website (may be down)" $LOGFILE
+ ;;
+
+ *)
+ # a generic failure
+ info "Unexpected child exit status; got $status, wanted 0"
+ maillog "${PROGNAME}: failed to update website" $LOGFILE
+ ;;
+ esac
+}
+
+##
+## Bootstrap
+##
+main "$@"
1.4 +17 -58 newsite/src/bin/update-website.sh
Index: update-website.sh
===================================================================
RCS file: /cvsroot/jboss/newsite/src/bin/update-website.sh,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- update-website.sh 2001/09/01 01:06:58 1.3
+++ update-website.sh 2001/09/01 02:20:53 1.4
@@ -6,17 +6,10 @@
## ##
### ====================================================================== ###
-# $Id: update-website.sh,v 1.3 2001/09/01 01:06:58 user57 Exp $
+# $Id: update-website.sh,v 1.4 2001/09/01 02:20:53 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"
@@ -24,10 +17,10 @@
CVS_OPTIONS="-q -r -f -z3 -d $CVSROOT"
# Where we will will work from
-WORKROOT="$HOME/tmp/jboss/update-website"
+WORKROOT="$HOME/tmp/update-website"
# Where we will deploy files too
-DEPLOYROOT="/home/jason/new/java/JBoss-2.4.0_Jetty-3.1.RC8-1/jboss/deploy" # change
this to $HOME/JBoss/jboss/deploy
+DEPLOYROOT="$HOME/website/deploy"
##
## Print an informative message
@@ -40,70 +33,38 @@
## Print an error message and exit
##
die() {
+ if [ "x$exitcode" = "x" ]; then
+ exitcode=1
+ fi
info $*
- exit 1
+ exit $exitcode
}
##
-## Mail out a log file to the MAILTO list
-##
-maillog() {
- subject=$1
- logfile=$2
-
- $MAIL $MAILTO -s "$subject" < $logfile
- info "Email notification sent to $MAILTO"
-}
-
-##
## Check the return status of child
##
checkStatus() {
have=$1
want=$2
message=$3
- logfile=$4
+ if [ "x$4" = "x" ]; then
+ exitcode=1
+ else
+ exitcode=$4
+ fi
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 WORKROOT: $WORKROOT"
rm -rf $WORKROOT
@@ -114,24 +75,22 @@
info "Pulling down a fresh copy of jboss-website"
$CVS $CVS_OPTIONS get -AP jboss-website
status=$?
- checkStatus $status 0 "cvs checkout failed" $logfile
+ checkStatus $status 0 "cvs checkout failed"
# enter the workspace dir so we can find tools correctly
cd jboss-website
# build the website
info "Building website"
- ./build/build.sh website
+ ./build/build.sh -Dsnapshot.cvsroot="$CVSROOT" website
status=$?
- checkStatus $status 0 "build 'website' failed" $logfile
- checkBuild "build 'website' was not successful" $logfile
+ checkStatus $status 0 "build 'website' failed"
# install the website
info "Installing website; DEPLOYROOT: $DEPLOYROOT"
- ./build/build.sh -Djboss.deploy.root=$DEPLOYROOT website-install
+ ./build/build.sh -Djboss.deploy.root="$DEPLOYROOT" website-install
status=$?
- checkStatus $status 0 "build 'website-install' failed" $logfile
- checkBuild "build 'website-install' was not successful" $logfile
+ checkStatus $status 0 "build 'website-install' failed" 2
# Clean up and say goodbye
info "Cleaning up WORKROOT"
_______________________________________________
Jboss-development mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/jboss-development