-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

There were some logic problems in my script (the $(...) construct in
bash doesn't return the return value, it returns the output of ...,
similar to the backtick  `` construct.).  I've fixed them here:

#!/bin/bash

BKUP_HOME=/mnt/backup/home
BKUP_MUSIC=/mnt/backup/music

EXPIRE=/usr/sbin/dirvish-expire
#EXP_OPTS="--quiet"
RUNALL=/usr/sbin/dirvish-runall
#RUN_OPTS="--quiet"


E_MNT_ALREADY_MOUNTED=32
E_UMNT_NOT_MOUNTED=1
E_SUCCESS=0

MNT=/bin/mount
UMNT=/bin/umount

# Mount the backup file systems
$MNT $BKUP_HOME
EXIT_STATUS=$?
if [ "$EXIT_STATUS" -ne "$E_SUCCESS" ];then
  if [ "$EXIT_STATUS" -ne "$E_MNT_ALREADY_MOUNTED" ]
  then
    echo "Failed to mount $BKUP_HOME!" 1>&2
    exit $?
  fi
fi

$MNT $BKUP_MUSIC
EXIT_STATUS=$?
if [ "$EXIT_STATUS" -ne "$E_SUCCESS" ];then
  if [ "$EXIT_STATUS" -ne "$E_MNT_ALREADY_MOUNTED" ]
  then
    echo "Failed to mount $BKUP_MUSIC!" 1>&2
    exit $?
  fi
fi

# Run dirvish-expire
$EXPIRE $EXP_OPTS
EXIT_STATUS=$?
if [ "$EXIT_STATUS" -ne "$E_SUCCESS" ]; then
  echo "$EXPIRE run failure!" 1>&2
  exit $?
fi

# Run dirvish-runall
$RUNALL $RUN_OPTS
EXIT_STATUS=$?
if [ "$EXIT_STATUS" -ne "$E_SUCCESS" ]; then
  echo "$RUNALL run failure!" 1>&2
  exit $?
fi

# Unmount the backup file systems
$UMNT $BKUP_HOME
EXIT_STATUS=$?
if [[ "$EXIT_STATUS" -ne "$E_SUCCESS" ]]; then
  if [[ "$EXIT_STATUS" -ne "$E_UMNT_NOT_MOUNTED" ]]
  then
    echo "Failed to unmount $BKUP_HOME!" 1>&2
    exit $?
  fi
fi

$UMNT $BKUP_MUSIC
EXIT_STATUS=$?
if [[ "$EXIT_STATUS" -ne "$E_SUCCESS" ]]; then
  if [[ "$EXIT_STATUS" -ne "$E_UMNT_NOT_MOUNTED" ]]
  then
    echo "Failed to unmount $BKUP_MUSIC!" 1>&2
    exit $?
  fi
fi

I took out the --quiet options for the time being since I'm getting sh
errors when I run the script from cron.  If I get those when my script
runs tomorrow (at roughly 00:00:00), I'll post with more info.
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.5 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iQEVAwUBRQfdDJ76rTZSI4F7AQIv8Af+M8I01g9lDShPLZoeOtYIonEt7uGkqR9E
HqA3KU4mI1Y3/m3QcP4Vil2WCYYTY/D3kHop1e9YaFj9KpNGM/yMw445FZWXsUvB
TYvysyCnp0YePPHyTEF28y+DSNPkdp41TLRSDtYsLrrZmSzkdZ9gcIKdZ78edbEz
ugk4YjD42qMGSqxop5H/enlNfSRkGtCOuGDZaMNVHheQwsZW8Z8J4fS+grw1NQIN
LR3Buk/IcpqyQawjkf5zETrtNB38QEtS62YJ6tQq8fYu0vVc6d/YCfOjPKj1sKZ3
sGAZqQ9pI1kOUALXeq6sGaUWs4UK6TDoDfpfy3YUXvyvIPfSqzbkAg==
=5+yk
-----END PGP SIGNATURE-----
_______________________________________________
Dirvish mailing list
[email protected]
http://www.dirvish.org/mailman/listinfo/dirvish

Reply via email to