[Fai-commit] r5918 - in trunk: bin debian
Thomas Lange
lange at alioth.debian.org
Fri Jul 30 15:22:03 UTC 2010
Author: lange
Date: 2010-07-30 15:21:59 +0000 (Fri, 30 Jul 2010)
New Revision: 5918
Modified:
trunk/bin/ftar
trunk/debian/changelog
Log:
ftar: die() subroutine now takes exit code, code cleanup
Modified: trunk/bin/ftar
===================================================================
--- trunk/bin/ftar 2010-07-30 15:08:59 UTC (rev 5917)
+++ trunk/bin/ftar 2010-07-30 15:21:59 UTC (rev 5918)
@@ -29,8 +29,12 @@
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
die() {
- echo "ftar died with error: $1"
- exit 99
+
+ local e=$1 # first parameter is the exit code
+ shift
+
+ echo "ftar died with error: $@" # print error message
+ exit $e
}
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
extract() {
@@ -102,28 +106,24 @@
[ "$debug" ] && vflag="-v"
[ "$debug" ] && echo "ftar: classes : $revclasses"
-[ -z "$source" ] && die "Source directory undefined."
-[ -z "$target" ] && die "Target directory undefined."
+[ -z "$source" ] && die 1 "Source directory undefined."
+[ -z "$target" ] && die 1 "Target directory undefined."
# currently only one directory is used
dir=$1
fpath=$source/$dir
-[ -d $fpath ] || die "No directory $fpath"
+[ -d $fpath ] || die 1 "No directory $fpath"
[ $deletefiles -eq 1 ] && cd $target/$dir && rm -f .* * 2>/dev/null
if [ $removedir -eq 1 ]; then
cd $target/$dir
- if [ $PWD = "/" ]; then
- echo "ftar WARNING: Will not do recursive removal of directory /"
- else
- rm -rf .* * 2>/dev/null
- fi
+ [ $PWD = "/" ] && die 3 "ftar WARNING: Will not do recursive removal of directory /"
+ rm -rf .* * 2>/dev/null
fi
for c in $revclasses ; do
# what if a directory exists which is equal to the hostname or a classname?
- # [ -f $fpath/$c ] && extract $fpath/$c cat
[ -f $fpath/$c.tgz ] && extract $fpath/$c.tgz zcat
[ -f $fpath/$c.tar ] && extract $fpath/$c.tar cat
[ -f $fpath/$c.tar.gz ] && extract $fpath/$c.tar.gz zcat
@@ -132,10 +132,7 @@
[ -f $fpath/$c.txz ] && extract $fpath/$c.txz xzcat
done
-if [ $tardone -eq 0 ]; then
- echo "ftar: No matching class found in $fpath"
- exit 1
-else
- exit 0
-fi
+[ $tardone -eq 0 ] && die 1 "ftar: No matching class found in $fpath"
+exit 0
+
Modified: trunk/debian/changelog
===================================================================
--- trunk/debian/changelog 2010-07-30 15:08:59 UTC (rev 5917)
+++ trunk/debian/changelog 2010-07-30 15:21:59 UTC (rev 5918)
@@ -100,6 +100,7 @@
* make-fai-nfsroot: die() subroutine now takes exit code, remove several
else branches
* savelog.LAST: add ignore pattern
+ * ftar: die() subroutine now takes exit code, code cleanup
[ Michael Tautschnig ]
* setup-storage: Bumped version number to 1.3
More information about the Fai-commit
mailing list