introduce _exit_err
This commit is contained in:
parent
9ec054053f
commit
afbab56496
2 changed files with 12 additions and 12 deletions
21
ccollect.sh
21
ccollect.sh
|
@ -15,15 +15,13 @@ CPOSTEXEC="$CDEFAULTS/post_exec"
|
||||||
|
|
||||||
TMP=$(mktemp /tmp/$(basename $0).XXXXXX)
|
TMP=$(mktemp /tmp/$(basename $0).XXXXXX)
|
||||||
VERSION=0.5.2
|
VERSION=0.5.2
|
||||||
RELEASE="2006-XXXXX"
|
RELEASE="2007-01-21"
|
||||||
HALF_VERSION="ccollect $VERSION"
|
HALF_VERSION="ccollect $VERSION"
|
||||||
FULL_VERSION="ccollect $VERSION ($RELEASE)"
|
FULL_VERSION="ccollect $VERSION ($RELEASE)"
|
||||||
|
|
||||||
#
|
#
|
||||||
# Date + Markup
|
|
||||||
# CDATE: how we use it for naming of the archives
|
# CDATE: how we use it for naming of the archives
|
||||||
# DDATE: how the user should see it in our output
|
# DDATE: how the user should see it in our output
|
||||||
# MDATE: how to match (shell expression) the date
|
|
||||||
#
|
#
|
||||||
CDATE="date +%Y-%m-%d-%H%M"
|
CDATE="date +%Y-%m-%d-%H%M"
|
||||||
DDATE="date"
|
DDATE="date"
|
||||||
|
@ -33,13 +31,11 @@ DDATE="date"
|
||||||
#
|
#
|
||||||
PARALLEL=""
|
PARALLEL=""
|
||||||
|
|
||||||
|
|
||||||
#
|
#
|
||||||
# catch signals
|
# catch signals
|
||||||
#
|
#
|
||||||
trap "rm -f \"$TMP\"" 1 2 15
|
trap "rm -f \"$TMP\"" 1 2 15
|
||||||
|
|
||||||
|
|
||||||
#
|
#
|
||||||
# Functions
|
# Functions
|
||||||
#
|
#
|
||||||
|
@ -47,6 +43,7 @@ trap "rm -f \"$TMP\"" 1 2 15
|
||||||
_exit_err()
|
_exit_err()
|
||||||
{
|
{
|
||||||
echo "$@"
|
echo "$@"
|
||||||
|
rm -f "$TMP"
|
||||||
exit 1
|
exit 1
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -84,13 +81,10 @@ if [ $# -lt 2 ]; then
|
||||||
fi
|
fi
|
||||||
|
|
||||||
#
|
#
|
||||||
# check for configuraton directory
|
# check for configuraton directory, FIXME: _exit_err
|
||||||
#
|
#
|
||||||
if [ ! -d "$CCOLLECT_CONF" ]; then
|
[ -d "$CCOLLECT_CONF" ] || _exit_err "No configuration found in " \
|
||||||
echo "No configuration found in \"$CCOLLECT_CONF\"" \
|
"\"$CCOLLECT_CONF\" (is \$CCOLLECT_CONF properly set?)"
|
||||||
" (is \$CCOLLECT_CONF properly set?)"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
#
|
#
|
||||||
# Filter arguments
|
# Filter arguments
|
||||||
|
@ -148,6 +142,7 @@ if [ -x "$CPREEXEC" ]; then
|
||||||
ret=$?
|
ret=$?
|
||||||
echo "Finished ${CPREEXEC}."
|
echo "Finished ${CPREEXEC}."
|
||||||
|
|
||||||
|
# FIXME: _exit_err
|
||||||
if [ $ret -ne 0 ]; then
|
if [ $ret -ne 0 ]; then
|
||||||
echo "$CPREEXEC failed, not starting backup."
|
echo "$CPREEXEC failed, not starting backup."
|
||||||
exit 1
|
exit 1
|
||||||
|
@ -167,6 +162,7 @@ if [ "$ALL" = 1 ]; then
|
||||||
cwd=$(pwd -P)
|
cwd=$(pwd -P)
|
||||||
( cd "$CSOURCES" && ls > "$TMP" )
|
( cd "$CSOURCES" && ls > "$TMP" )
|
||||||
|
|
||||||
|
# FIXME: _exit_err
|
||||||
if [ "$?" -ne 0 ]; then
|
if [ "$?" -ne 0 ]; then
|
||||||
echo "Listing of sources failed. Aborting."
|
echo "Listing of sources failed. Aborting."
|
||||||
exit 1
|
exit 1
|
||||||
|
@ -430,7 +426,8 @@ while [ "$i" -lt "$no_sources" ]; do
|
||||||
echo "Beginning to backup, this may take some time..."
|
echo "Beginning to backup, this may take some time..."
|
||||||
|
|
||||||
echo "Creating $destination_dir ..."
|
echo "Creating $destination_dir ..."
|
||||||
mkdir $VVERBOSE "$destination_dir" || exit 1
|
mkdir $VVERBOSE "$destination_dir" || \
|
||||||
|
_exit_err "Creating $destination_dir failed. Skipping."
|
||||||
|
|
||||||
#
|
#
|
||||||
# make an absolute path, perhaps $CCOLLECT_CONF is relative!
|
# make an absolute path, perhaps $CCOLLECT_CONF is relative!
|
||||||
|
|
|
@ -6,3 +6,6 @@ X join todos
|
||||||
* exclude
|
* exclude
|
||||||
* other
|
* other
|
||||||
* create _rsync, filtering args, creating new $@
|
* create _rsync, filtering args, creating new $@
|
||||||
|
- remove exit-calls
|
||||||
|
* will leave behind unused temporary file!
|
||||||
|
* use _exit_err
|
||||||
|
|
Loading…
Reference in a new issue