]> oss.titaniummirror.com Git - ovzbpc.git/blobdiff - bpcdump
Do not attempt to tee to $INFO if blank
[ovzbpc.git] / bpcdump
diff --git a/bpcdump b/bpcdump
index 2db202c32e8ef1991a9e79b26af440223981850e..254038a2a48ccbffd6fc358e546af1f08e7b3553 100755 (executable)
--- a/bpcdump
+++ b/bpcdump
@@ -1,6 +1,8 @@
 #!/bin/bash
 #
 # bpcdump
+# Version: __appVersion__
+#
 # Copyright (C) 2008-2012 by Titanium Mirror, Inc.
 # Author: R. Steve McKown <smckown@titaniummirror.com>
 #
@@ -26,12 +28,20 @@ CONF_DIR=/etc/vz/conf
 
 info()
 {
-    echo "$*" | tee -a "$INFO"
+    if [ -n "$INFO" ]; then
+       echo "$*" | tee -a "$INFO"
+    else
+       echo "$*"
+    fi
 }
 
 error()
 {
-    echo "$*" | tee -a "$INFO" >&2
+    if [ -n "$INFO" ]; then
+       echo "$*" | tee -a "$INFO" >&2
+    else
+       echo "$*"
+    fi
 }
 
 restartve()
@@ -147,11 +157,12 @@ else
 fi
 
 # Before we begin writing, remove old backup dirs until we have room.
+# Assume backups for any VE are fair game for removal if space is needed.
 # Other disk contents shall not be removed.
 dstblks=$(df -P "$EXTFS" | grep "$EXTFS" | awk '{ print $4 }')
 while [ $dstblks -le $srcblks ]; do
     info "Only $dstblks free on $EXTFS"
-    oldest=$(cd $EXTFS && eval ls -td "ve${VEID}*" 2>/dev/null | tail -1)
+    oldest=$(cd $EXTFS && eval ls -td "ve[0-9]*" 2>/dev/null | tail -1)
     if [ -z "$oldest" ]; then
       cleanup 1 "out of space: need $srcblks KB, have $dstblks KB"
     elif [ -d "$EXTFS/$oldest" ]; then