]> Frank Brehm's Git Trees - profitbricks/jenkins-build-scripts.git/commitdiff
make it work as expected
authorMathias Klette <mathias.klette@profitbricks.com>
Tue, 31 Jul 2012 10:35:38 +0000 (12:35 +0200)
committerMathias Klette <mathias.klette@profitbricks.com>
Tue, 31 Jul 2012 10:35:38 +0000 (12:35 +0200)
live_build.sh

index 0cf7790b1928341d213b3daa26455c2ba1a28fcf..0c2c8732130713ea185826d0e1f03874916a6be0 100755 (executable)
@@ -14,40 +14,40 @@ fi
 #
 if [ "$1" == "" ]
 then
-       LIVE_TYPE="staging"
+        LIVE_TYPE="staging"
 else
-       LIVE_TYPE=$1
+        LIVE_TYPE=$1
 fi
 
 #
 # Define default settings
 #
 RSYNC_BASE=/srv/mirror/live-build
-BUILD_DATE=$(date +%Y%m%d%H%M)
-BUILD_ID="${LIVE_TYPE}-${BUILD_DATE}-${BUILD_NUMBER}"          # BUILD_ID is used without lb_build.sh...
+BUILD_DATE=${BUILD_DATE:=$(date +%Y%m%d%H%M)}
+BUILD_ID="${LIVE_TYPE}-${BUILD_DATE}-${BUILD_NUMBER}"           # BUILD_ID is used without lb_build.sh...
 BUILD_TARGET=$RSYNC_BASE/$BUILD_ID
 
 #
 # Overwrite settings depending on profile used
 # - i.e. not enough space in PBB to contain all images
-# 
-case $LIVE_TYPE in 
+#
+case $LIVE_TYPE in
     default|staging)
         RSYNC_SRC="$RSYNC_BASE/"
         RSYNC_DST="livebuild@10.1.1.1/livebuild/"
-        RSYNC_FILTER="--filter=\"+ default-*\" --filter=\"+ staging-*\" --filter=\"- *\""
+        RSYNC_FILTER='--include=default-** --include=staging-** --exclude=*'
         ;;
     pbb|pre-staging)
         RSYNC_SRC="$BUILD_TARGET/"
         RSYNC_DST="livebuild@10.254.1.1/livebuild/"
-        RSYNC_FILTER="--filter=\"+ pbb-*\" --filter=\"+ pre-staging-*\" --filter=\"- *\""
+        RSYNC_FILTER=''
         ;;
 esac
 
 #
 # Export variables for upcoming sudo-calls
 #
-export LIVE_TYPE TARGET_RSYNC BUILD_DATE BUILD_ID BUILD_TARGET TARGET_BASE
+export LIVE_TYPE BUILD_DATE BUILD_ID BUILD_TARGET RSYNC_BASE RSYNC_SRC RSYNC_DST RSYNC_FILTER
 
 #
 # Build
@@ -63,7 +63,7 @@ ls -larth binary/live/
 
 figlet "build OK"
 
-# 
+#
 # Deploy
 #
 mkdir -p $BUILD_TARGET
@@ -91,17 +91,17 @@ figlet "mirror OK"
 
 #
 # cleanup /srv/mirror, keep MAX number of images
-# 
+#
 MAX=15
-cd $TARGET_BASE
+cd $RSYNC_BASE
 COUNT=0
-for i in $(ls -artd1 ./${LIVE_TYPE}-*) ; do
-       let COUNT=COUNT+1
-       if [ $COUNT -gt $MAX ] ; then
-               rm -rfv $i
-       else
-               echo "keeping $i"
-       fi
+for i in $(ls -atd1 ./${LIVE_TYPE}-*) ; do
+        let COUNT=COUNT+1
+        if [ $COUNT -gt $MAX ] ; then
+                rm -rfv $i
+        else
+                echo "keeping $i"
+        fi
 done
 
 figlet "cleanup OK"