2016-06-11 23:18:17 +00:00
|
|
|
#!/bin/bash
|
2014-07-21 01:01:25 +00:00
|
|
|
|
2016-06-11 23:18:17 +00:00
|
|
|
apply_base_data() {
|
|
|
|
contents=`ls $GITBLIT_BASE_FOLDER|wc -l`
|
2014-07-21 01:01:25 +00:00
|
|
|
|
2016-06-11 23:18:17 +00:00
|
|
|
if [ $contents = "0" ]; then
|
|
|
|
cp -r $GITBLIT_PATH/data/* $GITBLIT_BASE_FOLDER
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
apply_config() {
|
2016-06-27 16:16:09 +00:00
|
|
|
cp -rf /config/* $GITBLIT_BASE_FOLDER
|
2016-06-11 23:18:17 +00:00
|
|
|
}
|
|
|
|
|
2016-06-27 03:40:11 +00:00
|
|
|
create_repo() {
|
|
|
|
local repo_dir=$GITBLIT_BASE_FOLDER/git/$1.git
|
2016-06-11 23:18:17 +00:00
|
|
|
mkdir -p $repo_dir
|
|
|
|
cd $repo_dir
|
|
|
|
|
|
|
|
git init --bare
|
2016-06-27 03:40:11 +00:00
|
|
|
|
2016-06-11 23:18:17 +00:00
|
|
|
echo "
|
|
|
|
[gitblit]
|
|
|
|
description =
|
|
|
|
originRepository =
|
|
|
|
owner = $GITBLIT_ADMIN_USER
|
|
|
|
acceptNewPatchsets = true
|
|
|
|
acceptNewTickets = true
|
|
|
|
mergeTo = master
|
|
|
|
useIncrementalPushTags = false
|
|
|
|
allowForks = true
|
|
|
|
accessRestriction = PUSH
|
|
|
|
authorizationControl = AUTHENTICATED
|
|
|
|
verifyCommitter = false
|
|
|
|
showRemoteBranches = false
|
|
|
|
isFrozen = false
|
|
|
|
skipSizeCalculation = false
|
|
|
|
skipSummaryMetrics = false
|
|
|
|
federationStrategy = FEDERATE_THIS
|
|
|
|
isFederated = false
|
|
|
|
gcThreshold =
|
|
|
|
gcPeriod = 0
|
|
|
|
" >> config
|
|
|
|
|
|
|
|
git config --replace-all core.logallrefupdates false
|
|
|
|
|
2016-06-27 03:40:11 +00:00
|
|
|
echo "
|
|
|
|
CREATING repository '$1' with:
|
|
|
|
* read/clone access for all
|
|
|
|
* push access for authenticated users"
|
|
|
|
|
|
|
|
RET="file://$repo_dir"
|
|
|
|
}
|
|
|
|
|
|
|
|
apply_repos() {
|
|
|
|
for rdir in /repos/*; do
|
2016-06-27 13:30:54 +00:00
|
|
|
if [ -e $rdir/.git ]; then
|
2016-06-27 03:40:11 +00:00
|
|
|
r=$(basename $rdir)
|
|
|
|
create_repo $r
|
|
|
|
local url=$RET
|
|
|
|
cd $rdir
|
|
|
|
echo "* pushed existing content"
|
|
|
|
git push --all $url
|
|
|
|
fi
|
|
|
|
|
|
|
|
done
|
|
|
|
}
|
|
|
|
|
|
|
|
create_initial_repo() {
|
|
|
|
if [ -d $GITBLIT_INITIAL_REPO ]; then
|
|
|
|
return
|
|
|
|
fi
|
|
|
|
|
|
|
|
create_repo $GITBLIT_INITIAL_REPO
|
2016-06-11 23:18:17 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
shopt -s nullglob
|
2016-06-27 16:16:09 +00:00
|
|
|
if [ ! -f /var/local/gitblit_firststart ]; then
|
|
|
|
FIRSTSTART=1
|
|
|
|
else
|
|
|
|
FIRSTSTART=0
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ $FIRSTSTART = 1 ]; then
|
|
|
|
apply_base_data
|
2016-06-11 23:18:17 +00:00
|
|
|
|
2016-06-27 16:16:09 +00:00
|
|
|
echo "
|
|
|
|
Applying configuration from /config
|
|
|
|
"
|
2016-06-11 23:18:17 +00:00
|
|
|
apply_config
|
2016-06-27 16:16:09 +00:00
|
|
|
touch /var/local/gitblit_firststart
|
2016-06-11 23:18:17 +00:00
|
|
|
fi
|
|
|
|
|
2016-06-27 16:16:09 +00:00
|
|
|
|
2016-06-11 23:18:17 +00:00
|
|
|
if [[ -n $GITBLIT_INITIAL_REPO ]]; then
|
|
|
|
create_initial_repo
|
2014-07-21 01:01:25 +00:00
|
|
|
fi
|
2016-06-27 03:40:11 +00:00
|
|
|
apply_repos
|
2014-07-21 01:01:25 +00:00
|
|
|
|
2016-06-27 03:40:11 +00:00
|
|
|
cd $GITBLIT_PATH
|
2016-06-11 23:18:17 +00:00
|
|
|
$JAVA_HOME/bin/java -jar $GITBLIT_PATH/gitblit.jar \
|
|
|
|
--httpsPort $GITBLIT_HTTPS_PORT --httpPort $GITBLIT_HTTP_PORT \
|
|
|
|
--baseFolder $GITBLIT_BASE_FOLDER
|