Skip to content

Instantly share code, notes, and snippets.

@qbit
Created March 12, 2012 21:11
Show Gist options
  • Save qbit/2024705 to your computer and use it in GitHub Desktop.
Save qbit/2024705 to your computer and use it in GitHub Desktop.
Crappy dropbox clone using svn
#!/bin/bash
IFS=$'\n'
SYNC_DIRS=`cat directory_list.txt`
WD=`pwd`
function loop {
for dir in $SYNC_DIRS; do
cd $dir
IFS=$'\n'
STAT=`svn stat`
if [[ "$STAT" = "" ]]; then
echo "doing Nothing: $dir"
else
for line in $STAT; do
file=`echo $line | perl -p -w -e 's/\!\s*|\?\s*//g' | sed 's/ /\\ /g'`
if [[ "$line" = \?* ]]; then
if [ -d $file ]; then
cd $file
if [ -d .svn ]; then
rm -rf .svn
fi
fi
cd $dir
svn add $file
elif [[ "$line" = D* ]]; then
svn delete $file
elif [[ "$line" = !* ]]; then
svn delete $file
fi
done
echo "commiting change"
svn ci -m "AutoCommit" $dir
fi
echo "svn up $dir"
svn up
done
cd $WD
}
while true; do
loop
sleep 5
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment