File: git-repack-repositories-cron

package info (click to toggle)
git-stuff 11-1
  • links: PTS
  • area: main
  • in suites: wheezy
  • size: 468 kB
  • sloc: sh: 1,072; perl: 152; makefile: 128
file content (47 lines) | stat: -rwxr-xr-x 1,182 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#!/bin/sh

## Copyright (C) 2006-2011 Daniel Baumann <daniel.baumann@progress-technologies.net>
##
## This program comes with ABSOLUTELY NO WARRANTY; for details see COPYING.
## This is free software, and you are welcome to redistribute it
## under certain conditions; see COPYING for details.


set -e

if [ -e /etc/default/git-repack-repositories ]
then
	. /etc/default/git-repack-repositories
fi

if [ "${GIT_REPACK_REPOSITORIES_ENABLE}" != "true" ]
then
	# git-repack-repositories is disabled in /etc/default/git-repack-repositories
	exit 0
fi

if [ -z "${GIT_REPACK_REPOSITORIES_DIRECTORIES}" ]
then
	echo "E: git-repack-repositories has no directories in /etc/default/git-repack-repositories."
	exit 1
fi

for _USER_DIRECTORY in ${GIT_REPACK_REPOSITORIES_DIRECTORIES}
do
	if [ ! -e "${_USER_DIRECTORY}" ]
	then
		echo "W: ${_USER_DIRECTORY} - no such file or directory, skipping."
		continue
	fi

	cd "${_USER_DIRECTORY}"

	_SUB_DIRECTORIES="$(for _DIRECTORY in $(find . -type d -name "*.git"); do echo $(dirname $_DIRECTORY); done | sort -u)"

	for _SUB_DIRECTORY in ${_SUB_DIRECTORIES}
	do
		cd "${_SUB_DIRECTORY}"
		git-repack-repositories ${@}
		cd "${OLDPWD}"
	done
done