1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192 |
- #!/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} == "auto" ]] ;
- then
- if [[ -d "annex" ]] ;
- then
- echo Detected Git Annex
- git annex sync
- echo Annex Sync Complete
- else
- echo No Annex Sync
- 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
|