#!/bin/bash # # Copyright (c) 2003 Vinai Kopp # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA # # # # # trigger build of new exim-tls-mysql deb # based on current exim-tls version on # a buildhost, and download the .deb into # the current directory. # # PATH=/bin:/usr/bin:/usr/local/bin export PATH HOST=buildhost.example.com USER=www_authenticate_user PASS=www_authenticate_pass TRIGGERURL=https://$HOST/path/to/exim-tls-mysql.php BASEURL=https://$HOST/path/to/exim-tls-mysql STATUSURL=$BASEURL/status LOGURL=$BASEURL/log RESURL=$BASEURL/res DEBURL= DEB= OLDSTATUS= STATUS= BUILDLOG=/dev/null VERBOSE=0 usage() { echo "Usage: $0 [-v] [-b logfile]" echo "-b save the build process output to logfile" echo "-v watch the build process output" exit 1 } while [ -n "$1" ]; do if [ "-b" == "$1" ]; then shift if [ -z "$1" ]; then echo "No valid buildlog specified" >&2 exit 1 fi BUILDLOG="$1" elif [ "-v" == "$1" ]; then VERBOSE=$((VERBOSE +1)) elif [ "-h" == "$1" ]; then usage fi shift done echo "buildhost: $HOST" echo -n "pinging to check the host is alive... " if ! ping -c1 $HOST > /dev/null 2>&1; then echo "failed" exit 1 fi echo "ok" echo "triggering build (please be patient, this may take some time!)" if [ $VERBOSE -gt 0 ]; then echo curl --no-buffer -fu $USER:$PASS $TRIGGERURL 2>/dev/null | tee $BUILDLOG else curl -sSf -u $USER:$PASS $TRIGGERURL > $BUILDLOG 2>&1 & fi echo while [ 42 ]; do sleep 2 STATUS=$(curl -sSf -u $USER:$PASS $STATUSURL) if [[ -z "$OLDSTATUS" || "$STATUS" != "$OLDSTATUS" ]]; then echo "build status: $STATUS"; OLDSTATUS="$STATUS" fi if [[ "error" == "$STATUS" ]]; then echo -e "Error during build\n" >&2 curl -fu $USER:$PASS $LOGURL >&2 exit 1 fi if [[ "ok" == "$STATUS" ]]; then break; fi sleep 13 done echo "fetching the url of the built .deb" DEB=$(curl -sSf -u $USER:$PASS $RESURL) DEBURL="${BASEURL}/$DEB" echo "downloading $DEBURL" if ! curl --progress-bar -f -O -u $USER:$PASS $DEBURL; then exit $? fi echo "exim-tls-mysql package is $DEB" exit 0