Skip to content

Commit

Permalink
Describe how to administrate git repositories
Browse files Browse the repository at this point in the history
- Expand documentation in README.
- Add a simple script to add repositories.

Close #5
  • Loading branch information
foretspaisibles committed May 28, 2024
1 parent 0827806 commit 483c27f
Show file tree
Hide file tree
Showing 4 changed files with 68 additions and 15 deletions.
18 changes: 18 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -259,6 +259,24 @@ CID/USER> (operation:start-project *local*)
CID/USER> (operation:stop-project *local*)
~~~

## Administration of GITSERVER

The current server certainly needs to be replaced by a git-tea
instance. However it is still here and the following instructions are
about configuring it and running.

### Authorized Keys

~~~ console
docker exec -it "${PROJECT_NAME}-gitserver-1" vi /var/git/.ssh/authorized_keys
~~~

### Create a Repository

~~~
$ docker exec -it "${PROJECT_NAME}-gitserver-1" /usr/local/bin/create_repository TRACNAME REPOSITORYNAME
~~~

## Free software

El Cid is free software: copying it and redistributing it is very
Expand Down
1 change: 1 addition & 0 deletions docker/image/gitserver/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ RUN chown -R cid:cid /opt/cid/var/src/cid/support
RUN sh /root/setup/support.sh

COPY ./docker/image/gitserver/sudoers-gitserver /etc/sudoers.d/gitserver
COPY ./docker/image/gitserver/create_repository /usr/local/bin/create_repository
COPY ./docker/image/gitserver/entrypoint /usr/local/bin/entrypoint
ENTRYPOINT ["/usr/local/bin/entrypoint"]
VOLUME ["/var/git"]
Expand Down
49 changes: 49 additions & 0 deletions docker/image/gitserver/create_repository
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
#!/bin/sh

# create_repository.sh — Create a Repository

# El Cid (https://github.com/melusina-org/cid)
# This file is part of El Cid.
#
# Copyright © 2015–2024 Michaël Le Barbier
# All rights reserved.

# This file must be used under the terms of the MIT License.
# This source file is licensed as described in the file LICENSE, which
# you should have received as part of this distribution. The terms
# are also available at https://opensource.org/licenses/MIT

: ${gitdir:=/var/git}
: ${tracdir:=/var/trac}

main()
{
local repository
case "$#-$1-$2" in
2-*-*.git)
environment="${tracdir}/$1"
shortname="${2%.git}"
repository="${gitdir}/$1/$2"
;;
2-*-*)
environment="${tracdir}/$1"
shortname="$2"
repository="${gitdir}/$1/$2.git"
;;
*)
failwith 'gitserver_create_repository'
esac

install -d -o git -g git -m 750 "${repository}"
su -l git -s /bin/sh -c "git init --bare ${repository}"
su -l www-data -s /bin/sh -c "trac-admin ${environment} repository add ${shortname} ${repository} git"
(
cd "${repository}/hooks"
rm -f post-receive
ln -s /opt/cid/libexec/cid/cid_githook_postreceive post-receive
)
}

main "$@"

# End of file `create_repository.sh'
15 changes: 0 additions & 15 deletions support/cid_githook_postreceive.sh
Original file line number Diff line number Diff line change
Expand Up @@ -73,19 +73,4 @@ policy_trac_add_changeset()

policy_trac_add_changeset


### IMPLEMENTATION

# Redirect output to stderr.
exec 2>>/var/log/cid_hithook_postreceive.log
exec 1>&2

set -x

# Save list of incoming commits in tmpfile
tmpfile_initializer postreceivedata
cat > "${postreceivedata}"

policy_trac_add_changeset < "${postreceivedata}"

# End of file `cid_githook_postreceive.sh'

0 comments on commit 483c27f

Please sign in to comment.