#!/bin/bash #Wrapper for unison (filesystem syncronizer) #Edits unison's config file depending on which host you are #You can use it to synchronize your data between two machiness (Laptop - PC) #On both machines you only need to type "unison-wrapper.sh" # # This script is unsupported. My girfriend has my old PC and I have a new # laptop. ### Start Config ONE=sonne TWO=thinkpad CONFIG="$HOME/.unison/default.prf" SYN_HOME=$HOME ### End Config cd $SYN_HOME HERE=`uname -n` if [ $HERE = $ONE ]; then THERE=$TWO elif [ $HERE = $TWO ]; then THERE=$ONE else echo "You are neigther on $ONE nor $TWO" echo "You are on: $HERE" echo "Exiting" exit fi TMPFILE=`mktemp /tmp/unison.XXXXXX` cp $CONFIG $CONFIG.saved grep -vE '^root' $CONFIG | grep -vE '^#-' > $TMPFILE rm $CONFIG echo "#- Automatically edited by unison-wrapper.sh" >> $CONFIG echo "#- You may edit this file." >> $CONFIG echo "#- Lines beginning with 'root' will be deleted" >> $CONFIG echo "#- These lines will be generated depending on " >> $CONFIG echo "#- which host you are" >> $CONFIG echo "root = ssh://$THERE/$SYN_HOME" >> $CONFIG echo "root = $SYN_HOME" >> $CONFIG cat $TMPFILE >> $CONFIG unison -auto default