moved to new name since less used
[feisty_meow.git] / customize / fred / scripts / musical_wand.sh
1 #!/bin/bash
2
3 # musical_wand: distributes music from our primary source to all hosts that are listed
4 # as being redundant copies for the music.
5
6 # this script is designed to be run on the music host with the super alpha main source of
7 # music plugged in as an external drive.  that being said, it will still work as long as
8 # the music host has its local copy intact; the local copy of the primary is always what
9 # is synched onto the other archive hosts.  in that sense, the musical host is itself a
10 # musix archive, but it is treated "special".
11
12 source "$FEISTY_MEOW_SCRIPTS/core/functions.sh"
13
14 #hmmm: add the goodness around these actions like the "nice" updater so we catch all errors.
15
16 # this host is where all the music is supposed to come from.
17 MUSICAL_HOST=curie
18
19 #hmmm: this script is currently limited to run ON the music host.  it could easily do the backwards thing instead, and copy FROM music host.
20
21 # the list of hosts we know of that are holding onto duplicate copies of the musix archive.
22 MUSIX_ARCHIVE_SITE_LIST=(surya banshee wildmutt euphrosyne)
23
24
25 if [[ ! ( $(hostname) =~ .*${MUSICAL_HOST}.* ) ]]; then
26   echo "This script is only designed to run on $MUSICAL_HOST with the"
27   echo "primary fred music source (external) disc plugged in."
28   exit 1
29 fi
30
31 # synch our local copy on the music host with the primary music drive, source of all goodness.
32 function get_music_from_alpha_site()
33 {
34   sep
35   echo "getting musix and basement from fred music prime device"
36   rsync -av /media/fred/fredmusicprime/musix/* /z/musix/
37   rsync -av /media/fred/fredmusicprime/basement/* /z/basement/
38   sep
39   echo
40 }
41
42 # updates the music on a remote host to our current local copy on the music host.
43 function update_musix_pile()
44 {
45   sep
46   local host="$1"; shift
47   echo "$host: synching musix and basement"
48   rsync -avz /z/musix/* ${host}:/z/musix/ 
49   rsync -avz /z/basement/* ${host}:/z/basement/ 
50   sep
51   echo
52 }
53
54 ##############
55
56 # make sure the local machine, our first-stop musix host, is in good shape.
57 get_music_from_alpha_site
58
59 # run through the steps of updating all our machines.
60 for i in ${MUSIX_ARCHIVE_SITE_LIST[@]}; do
61   update_musix_pile $i
62 done
63
64