123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990 |
- #!/usr/bin/bash
- ORIGDIR=$(pwd)
- ANNEXFLAG=auto
- GCFLAG=false
- IDENTFLAG=false
- while getopts "haAlgi" opt ;
- do
- case "$opt" in
- h)
- cat <<EOF >&2
- $0 [ -h | -a | -A | -l | -g | -i ]*
- -h Show Help
- -a Always sync annex
- -A Do not sync annex
- -l List Repositories
- -g Run GC
- -i Use an identity
- EOF
- exit 1
- ;;
- a)
- ANNEXFLAG=true
- ;;
- A)
- ANNEXFLAG=false
- ;;
- l)
- find . -type d -name '*.git'
- exit
- ;;
- g)
- GCFLAG=true
- ;;
- i)
- IDENTFLAG=true
- ;;
- esac
- done
- if [[ ${IDENTFLAG} == "true" ]] ;
- then
- ssh-add id_backup_drive
- fi
- find . -type d -name '*.git' | \
- while read -r repository
- do
- cd "${repository}"
- echo "In $(echo "${repository}" | sed -e 's/^\.\///g' -e 's/\.git$//g'):"
- git fetch
-
- if [[ ${ANNEXFLAG} == "detect" ]] ;
- then
- if [[ -d "annex" ]] ;
- then
- echo Detected Git Annex
- git annex sync
- echo Annex Sync Complete
- fi
- elif [[ ${ANNEXFLAG} == "true" ]] ;
- then
- echo Forcing Git Annex
- git annex sync
- echo Annex Sync Complete
- else
- echo No Annex Sync
- fi
- if [[ ${GCFLAG} == "true" ]] ;
- then
- echo Performing GC/FSCK
- git gc --aggressive
- git fsck
- echo GC/FSCK Complete
- else
- echo No GC/FSCK
- fi
- cd "${ORIGDIR}"
- echo
- done
- if [[ ${IDENTFLAG} == "true" ]] ;
- then
- ssh-add -d id_backup_drive
- fi
|