Created
March 12, 2012 21:11
-
-
Save qbit/2024705 to your computer and use it in GitHub Desktop.
Crappy dropbox clone using svn
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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