#!/bin/sh

rsync -Pavze ssh picard.snowman.net:sync .

if [ ! -e $HOME/.sync_config ]; then
   touch $HOME/.sync_config

   for i in `perl -lne 'next if (/^#/ or /^$/ or /^\s$/); @l = split /,/; chomp @l; next unless ($l[1] eq "config"); print "$l[0]\n";' < sync/config.csv `; do

      if [ -e $HOME/$i ]; then
         new=$(echo $HOME/$i | sed 's/\./_/')"-sync_config-backup"
         echo  "$HOME/$i exists. moving to $new";
         mv $HOME/$i $new
      fi

      ln -sf `pwd`/sync/`echo $i | sed 's/\./_/'` $HOME/$i
   done
fi

