Merge branch 'dev' of feistymeow.org:feisty_meow into testing
[feisty_meow.git] / scripts / customize / fred / scripts / disk_synch / 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/launch_feisty_meow.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 #old list MUSIX_ARCHIVE_SITE_LIST=(surya banshee wildmutt euphrosyne)
23 MUSIX_ARCHIVE_SITE_LIST=(euphrosyne)
24 #hmmm: list was contracted a lot, since we don't want to step on the updates done by syncthing.  euphrosyne is still our reference copy for what the archive states "should" be.
25
26 if [[ ! ( $(hostname) =~ .*${MUSICAL_HOST}.* ) ]]; then
27   echo "This script is only designed to run on $MUSICAL_HOST with the"
28   echo "primary fred music source (external) disc plugged in."
29   exit 1
30 fi
31
32 # synch our local copy on the music host with the primary music drive, source of all goodness.
33 function get_music_from_alpha_site()
34 {
35   sep
36   echo "getting musix and basement from fred music prime device"
37   rsync -av /media/fred/fredmusicprime/musix/* /z/musix/
38   rsync -av /media/fred/fredmusicprime/basement/* /z/basement/
39   sep
40   echo
41 }
42
43 # updates the music on a remote host to our current local copy on the music host.
44 function update_musix_pile()
45 {
46   sep
47   local host="$1"; shift
48   echo "$host: synching musix and basement"
49   rsync -avz /z/musix/* ${host}:/z/musix/ 
50   rsync -avz /z/basement/* ${host}:/z/basement/ 
51   sep
52   echo
53 }
54
55 ##############
56
57 # make sure the local machine, our first-stop musix host, is in good shape.
58 get_music_from_alpha_site
59
60 # run through the steps of updating all our machines.
61 for i in ${MUSIX_ARCHIVE_SITE_LIST[@]}; do
62   update_musix_pile $i
63 done
64
65