GEARZ.de

All snippets are without any warranty.
Alle Snippets sind ohne jegliche Gewähr oder Garantie.



changeTMvolume.command:   <back to snippets>   <back to howtos>

#!/bin/bash
# 090218 tatze v1.0

# change the mount-path to your 1st volumes mount
intern=""

# insert 104 sign-columns of the 2nd volume here (vol1)
internID=""

# change the mount-path to your 2nd volumes mount
extern=""

# insert 104 sign-columns of the 2nd volume here (vol2)
externID="" 

# stop editing :)
host=`hostname -s`

if [ -d $intern ]
  then
  if [ -d $extern ]
    then
    ex=`ps -A | grep /System/Library/CoreServices/backupd | grep -v grep`
    if test "$ex"
      then
      exit
    else
      status=`defaults read /Library/Preferences/com.apple.TimeMachine "BackupAlias"`
      if test "$status" = "$internID"
        then
        if test "$intern/Backups.backupdb/$host" -nt "$extern/Backups.backupdb/$host"
          then
          status="extern"
          ex=`defaults write /Library/Preferences/com.apple.TimeMachine "BackupAlias" "$externID"`
        else
          exit
        fi
      else
        if test "$extern/Backups.backupdb/$host" -nt "$intern/Backups.backupdb/$host"
          then
          status="intern"
          ex=`defaults write /Library/Preferences/com.apple.TimeMachine "BackupAlias" "$internID"`
        else
          exit
        fi
      fi
      /usr/local/bin/growlnotify -n TM -m "changed TM-Volume to $status" -t "TM Volumechange"
    fi
  else
    /usr/local/bin/growlnotify -s -n TM -m "TM-Volume EXTERN unmounted!" -t "TM Volumechange FAILED"
    exit
  fi
else
  /usr/local/bin/growlnotify -s -n TM -m "TM-Volume INTERN unmounted!" -t "TM Volumechange FAILED"
  exit
fi
exit