Removing 'exit 1'; using 'fatal' instead (Redmine#3721)

This commit is contained in:
Silvio Rhatto 2011-12-31 20:03:02 -02:00 committed by intrigeri
parent 926152dfa1
commit 10d67587ef

View File

@ -230,19 +230,16 @@ function eval_config {
if [ "$dest" != "local" ] && [ "$from" == "remote" ]; then if [ "$dest" != "local" ] && [ "$from" == "remote" ]; then
fatal "When source is remote, destination should be local." fatal "When source is remote, destination should be local."
exit 1
fi fi
if [ "$from" != "local" ] && [ "$from" != "remote" ]; then if [ "$from" != "local" ] && [ "$from" != "remote" ]; then
fatal "Invalid source $from" fatal "Invalid source $from"
exit 1
fi fi
backupdir="$mountpoint/$backupdir" backupdir="$mountpoint/$backupdir"
if [ "$dest" == "local" ] && [ ! -d "$backupdir" ]; then if [ "$dest" == "local" ] && [ ! -d "$backupdir" ]; then
error "Backupdir $backupdir does not exist" fatal "Backupdir $backupdir does not exist"
exit 1
fi fi
if [ ! -z "$log" ]; then if [ ! -z "$log" ]; then
@ -589,22 +586,19 @@ function setup_long_dirs {
if [ -d $tmpdir ]; then if [ -d $tmpdir ]; then
mv $tmpdir $dir.1 mv $tmpdir $dir.1
if [ $? == 1 ]; then if [ $? == 1 ]; then
echo "Fatal: could mv $destdir/rotate.tmp $dir.1 on host $host" fatal "Could not move $tmpdir to $dir.1 on host $host"
exit 1
fi fi
else else
mkdir --parents $dir.1 mkdir --parents $dir.1
if [ $? == 1 ]; then if [ $? == 1 ]; then
echo "Fatal: could not create directory $dir.1 on host $host" fatal "Could not create directory $dir.1 on host $host"
exit 1
fi fi
fi fi
if [ -d $dir.2 ]; then if [ -d $dir.2 ]; then
echo "Debug: update links $backuptype.2 --> $backuptype.1" echo "Debug: update links $backuptype.2 --> $backuptype.1"
cp -alf $dir.2/. $dir.1 cp -alf $dir.2/. $dir.1
#if [ $? == 1 ]; then #if [ $? == 1 ]; then
# echo "Fatal: could not create hard links to $dir.1 on host $host" # fatal "Could not create hard links to $dir.1 on host $host"
# exit 1
#fi #fi
fi fi
fi fi
@ -705,7 +699,6 @@ function prepare_storage {
btype=monthly btype=monthly
else else
fatal "keeping no backups"; fatal "keeping no backups";
exit 1
fi fi
suffix="$btype.1" suffix="$btype.1"
@ -724,7 +717,6 @@ function prepare_storage {
suffix="" suffix=""
else else
fatal "Invalid backup format $format" fatal "Invalid backup format $format"
exit 1
fi fi
} }
@ -768,7 +760,6 @@ function set_batch_mode {
batch_option="--read-batch=$batch_file" batch_option="--read-batch=$batch_file"
else else
fatal "Batch file not found: $batch_file" fatal "Batch file not found: $batch_file"
exit 1
fi fi
elif [ "$batch" == "write" ]; then elif [ "$batch" == "write" ]; then
mkdir -p `dirname $batch_file` mkdir -p `dirname $batch_file`
@ -813,7 +804,6 @@ function test_connect {
if [ -z "$host" ] || [ -z "$user" ]; then if [ -z "$host" ] || [ -z "$user" ]; then
fatal "Remote host or user not set" fatal "Remote host or user not set"
exit 1
fi fi
debug "$ssh_cmd 'echo -n 1'" debug "$ssh_cmd 'echo -n 1'"
@ -821,7 +811,6 @@ function test_connect {
if [ "$result" != "1" ]; then if [ "$result" != "1" ]; then
fatal "Can't connect to $host as $user." fatal "Can't connect to $host as $user."
exit 1
else else
debug "Connected to $host successfully" debug "Connected to $host successfully"
fi fi
@ -915,7 +904,6 @@ function set_rsync_options {
if [ "$protocol" == "ssh" ]; then if [ "$protocol" == "ssh" ]; then
if [ ! -e "$id_file" ]; then if [ ! -e "$id_file" ]; then
fatal "SSH Identity file $id_file not found" fatal "SSH Identity file $id_file not found"
exit 1
else else
debug RSYNC_RSH=\"$ssh_cmd_base\" debug RSYNC_RSH=\"$ssh_cmd_base\"
echo RSYNC_RSH=\"$ssh_cmd_base\" >> $log echo RSYNC_RSH=\"$ssh_cmd_base\" >> $log
@ -970,8 +958,7 @@ function mount_rw {
if [ -d "$mountpoint" ]; then if [ -d "$mountpoint" ]; then
mount -o remount,rw $mountpoint mount -o remount,rw $mountpoint
if (($?)); then if (($?)); then
error "Could not mount $mountpoint" fatal "Could not mount $mountpoint"
exit 1
fi fi
fi fi
fi fi