From 29463878401499672150f2a3469bf8e8b9bff17b Mon Sep 17 00:00:00 2001
From: Silvino Silva Copy public key that will be used for
authenticating gitolite administrator, read
ssh how to
- create one.
# mkdir -p /srv/gitolite
- # useradd -U -d /srv/gitolite gitolite
+ # useradd -r -s /bin/bash -m -d /srv/gitolite gitolite
# chown gitolite:gitolite /srv/gitolite
@@ -38,10 +38,20 @@
- $ sudo install -o gitolite -g gitolite /home/bob/.ssh/gitolite.pub /srv/gitolite/gitolite.pub + $ scp /home/bob/.ssh/gitolite.pub admin@core.privat-network.net:/home/admin/ + bob@core.privat-network.net's password: + gitolite.pub 100% 390 0.4KB/s 00:00 ++ +
Then on remote machine;
+ +
+ # cp /home/admin/gitolite.pub /srv/gitolite.pub
@@ -62,7 +72,7 @@
- $ ssh -v -i ~/.ssh/gitulite_rsa gitolite@localhost -p 2222
+ $ ssh -v -i ~/.ssh/gitolite gitolite@localhost -p 2222
- $ git clone gitolite:gitolite-admin
+ $ git clone git-admin:gitolite-admin
+ @guests = gitweb
+ @interns = clair bob
@dev = alice david
- @interns = clair
- @dev = bob
@teamleads = mike
@staff = @interns @dev @teamleads
- @proj-repos = sysdoc storm atom
+
+ repo gitolite-admin
+ RW+ = gitolite
repo @floss
R = @all
@@ -141,24 +153,23 @@
repo @proto
RW+ = @staff
- repo @proj-repos
+ repo @project
RW+ = @teamleads
- master = @dev
- refs/tags/v[0-9] = @dev
RW+ develop/ = @dev
- RW+ feature/ = @dev
- RW+ hot-fix/ = @dev
+ RW+ feature/ = @dev @interns
+ RW+ hot-fix/ = @dev @interns
RW = @dev
- R = @managers
+ R = @interns @guests
- repo atom sysdoc
- option hook.post-receive = deployweb
+ @project = c9-doc c9-ports
+
+ repo c9-doc c9-ports
+ option hook.post-receive = hook-deployweb
repo testing
RW+ = @staff
-
- repo gitolite-admin
- RW+ = mike
Commit and push;
@@ -174,13 +185,13 @@
# cd /srv/gitolite/repositories/
- # mv void.git sysdoc.git
+ # mv void.git c9-doc.git
On workstation edit conf/gitolite.conf;
- repo sysdoc
+ repo c9-doc
RW+ = bob
@@ -196,7 +207,8 @@
Example from Cookbook how to apply hooks only to certain repos. Uncomment or add - this line on /srv/gitolite/.gitolite.rc, within the %RC block;
+ this line on /srv/gitolite/.gitolite.rc, + within the %RC block;
LOCAL_CODE => "$rc{GL_ADMIN_BASE}/local",
@@ -205,33 +217,30 @@
Uncomment the 'repo-specific-hooks' line in the rc file
or add it to the ENABLE list if it doesn't exist.
-
- GIT_CONFIG_KEYS => '.*',
-
-
# allow repo-specific hooks to be added
'repo-specific-hooks',
- Put your hooks into your gitolite-admin clone, as follows:
+ Create directory on gitolite-admin clone;
$ cd ~/gitolite-admin
$ mkdir -p local/hooks/repo-specific
- Create the same directory on remote as gitolite;
+ Now add your hooks to that directory, but instead of using the
+ git "standard" names (pre-receive, post-receive, post-update),
+ you use descriptive names (e.g. "deploy", "RSS-post", etc).
+
+ On remote run;
# su - gitolite
- $ mkdir local/hooks/repo-specific
+ $ mkdir .gitolite/local/hooks/repo-specific
+ $ gitolite setup
- Now add your hooks to that directory, but instead of using the
- git "standard" names (pre-receive, post-receive, post-update),
- you use descriptive names (e.g. "deploy", "RSS-post", etc).
-
4.1. Deploy Hook
This manual create two users; one gitolite that handle git
@@ -244,12 +253,8 @@
calls a script inside project folder with user www. This allows to
do post deploy (checkout) tasks such as composer update.
- Create deployweb
- in gitolite-admin/local/hooks/repo-specific;
-
-
- $ vim ~/gitolite-admin/local/hooks/repo-specific/deployweb
-
+ Create
+ gitolite-admin/local/hooks/repo-specific/hook-deployweb;
#!/bin/bash
@@ -257,7 +262,7 @@
######################################################################
#
# Put this file in your gitolite-admin;
- # ~/gitolite-admin/local/hooks/repo-specific/deployweb
+ # ~/gitolite-admin/local/hooks/repo-specific/hook-deployweb
#
while read oldrev newrev refname
do
@@ -277,19 +282,12 @@
done
- Create deploy directory on remote;
-
-
- # su - gitolite
- $ mkdir deploy
-
-
Add scripts to the repos you want them to be active in
your conf file. For example:
- repo atom @baz
- option hook.post-receive = deployweb
+ repo c9-doc
+ option hook.post-receive = hook-deployweb
Add, commit, and push the admin repo;
@@ -298,6 +296,13 @@
$ git add -u && git commit -m "deploy hook"
+ Create deploy directory on remote;
+ ++ # su - gitolite + $ mkdir deploy ++
On remote run;
@@ -310,117 +315,205 @@
/srv/gitolite/deploy folder for projects that have
been updated.
- Create deploy.sh in
- /usr/share/gitolite;
+ Create /usr/share/gitolite/hooks/deployweb;
- $ vim /usr/share/gitolite/deploy.sh
+ #!/bin/sh
+
+ ######################################################################
+ #
+ # Put this file in;
+ # /usr/share/gitolite/hooks/deployweb
+ #
+ DIR_WWW=/srv/www/
+ DEPLOY_BRANCH=master
+ TARGET_USER=www
+
+ for DP_FILE in /srv/gitolite/deploy/*
+ do
+
+ if [ ! -f "$DP_FILE" ]; then
+ # Nothing to do ;)
+ #echo "Deploy: invalid DP_FILE"
+ exit 1;
+ fi
+
+ # Get project name
+ PROJECT=$(basename "$DP_FILE")
+ echo "Deploy: PROJECT=${PROJECT}"
+
+ # Get git repository path and verify if exists
+ DIR_GIT=$(head -n 1 $DP_FILE)
+ if [ ! -d "$DIR_GIT" ]; then
+ echo "Deploy: invalid DIR_GIT: ${DIR_GIT}"
+ exit 2;
+ fi
+ echo "Deploy: DIR_GIT=${DIR_GIT}"
+
+ # Get directory to deploy and verify if exists
+ GIT_WORK_TREE=${DIR_WWW}${PROJECT}/
+ if [ ! -d "$GIT_WORK_TREE" ]; then
+ echo "Deploy: invalid GIT_WORK_TREE: ${GIT_WORK_TREE}"
+ echo "Deploy: creating directory: $GIT_WORK_TREE}"
+ mkdir -p $GIT_WORK_TREE
+ fi
+ echo "Deploy: GIT_WORK_TREE={$GIT_WORK_TREE}"
+
+ # Deploy (checkout)
+ echo "Deploy: starting git checkout"
+
+ git --git-dir=$DIR_GIT \
+ --work-tree=$GIT_WORK_TREE \
+ checkout -f $DEPLOY_BRANCH
+
+
+ # Fix ownership and permissions
+ echo "Deploy: fixing permissions"
+
+ echo "Deploy: setting owner: chown -R ${TARGET_USER}"
+ chown -R ${TARGET_USER}:${TARGET_USER} $GIT_WORK_TREE
+
+ echo "Deploy: setting directory permissions: chmod 755"
+ find $GIT_WORK_TREE -type d -print0 | xargs -0 chmod 755
+
+ echo "Deploy: setting file permissions: chmod 644"
+ find $GIT_WORK_TREE -type f -print0 | xargs -0 chmod 644
+
+ # Call project script
+ if [ -f "${GIT_WORK_TREE}/deploy.sh" ]; then
+ echo "Deploy: calling ${GIT_WORK_TREE}deploy.sh"
+ cd ${GIT_WORK_TREE}
+ sudo -u ${TARGET_USER} sh ${GIT_WORK_TREE}deploy.sh
+ fi
+
+ # Done with project
+ echo "Deploy: removing deploy file="$DP_FILE
+ rm $DP_FILE
+
+ exit 0;
+ done
-
- #!/bin/sh
+ Add cron job to call deploy script every minute;
- ######################################################################
- #
- # Put this file in;
- # /usr/share/gitolite/deploy.sh
- #
- DIR_WWW=/srv/www/
- DEPLOY_BRANCH=master
- TARGET_USER=www
+
+ # crontab -e
+
- for DP_FILE in /srv/gitolite/deploy/*
- do
+
+ #
+ # /etc/crontab: crond(8) configuration
+ #
- if [ ! -f "$DP_FILE" ]; then
- # Nothing to do ;)
- #echo "Deploy: invalid DP_FILE"
- exit 1;
- fi
+ # this way it will log
+ # * * * * * /usr/share/gitolite/hooks/deployweb
+ # without log
+ * * * * * /usr/share/gitolite/hooks/deployweb > /dev/null 2>&1
- # Get project name
- PROJECT=$(basename "$DP_FILE")
- echo "Deploy: PROJECT=${PROJECT}"
+ @hourly ID=sys.hourly /usr/sbin/runjobs /etc/cron/hourly
+ @daily ID=sys.daily /usr/sbin/runjobs /etc/cron/daily
+ @weekly ID=sys.weekly /usr/sbin/runjobs /etc/cron/weekly
+ @monthly ID=sys.monthly /usr/sbin/runjobs /etc/cron/monthly
- # Get git repository path and verify if exists
- DIR_GIT=$(head -n 1 $DP_FILE)
- if [ ! -d "$DIR_GIT" ]; then
- echo "Deploy: invalid DIR_GIT: ${DIR_GIT}"
- exit 2;
- fi
- echo "Deploy: DIR_GIT=${DIR_GIT}"
+ # End of file
+
- # Get directory to deploy and verify if exists
- GIT_WORK_TREE=${DIR_WWW}${PROJECT}/
- if [ ! -d "$GIT_WORK_TREE" ]; then
- echo "Deploy: invalid GIT_WORK_TREE: ${GIT_WORK_TREE}"
- echo "Deploy: creating directory: $GIT_WORK_TREE}"
- mkdir -p $GIT_WORK_TREE
- fi
- echo "Deploy: GIT_WORK_TREE={$GIT_WORK_TREE}"
+ 5. Gitweb
- # Deploy (checkout)
- echo "Deploy: starting git checkout"
+
+ $ prt-get depinst p5-cgi p5-cgi-session libcgi fcgiwrap spawn-fcgi
+
- git --git-dir=$DIR_GIT \
- --work-tree=$GIT_WORK_TREE \
- checkout -f $DEPLOY_BRANCH
+ 5.1. Configure gitweb
+ Edit /etc/gitweb.conf
- # Fix ownership and permissions
- echo "Deploy: fixing permissions"
+
+ our $git_temp = "/tmp";
- echo "Deploy: setting owner: chown -R ${TARGET_USER}"
- chown -R ${TARGET_USER}:${TARGET_USER} $GIT_WORK_TREE
+ # The directories where your projects are. Must not end with a slash.
+ our $projectroot = "/srv/gitolite/repositories";
- echo "Deploy: setting directory permissions: chmod 755"
- find $GIT_WORK_TREE -type d -print0 | xargs -0 chmod 755
+ # Base URLs for links displayed in the web interface.
+ our @git_base_url_list = qw(git://core.privat-network.com http://git@core.private-network.com);
+
- echo "Deploy: setting file permissions: chmod 644"
- find $GIT_WORK_TREE -type f -print0 | xargs -0 chmod 644
+ 5.2. Configure nginx
- # Call project script
- if [ -f "${GIT_WORK_TREE}/deploy.sh" ]; then
- echo "Deploy: calling ${GIT_WORK_TREE}deploy.sh"
- cd ${GIT_WORK_TREE}
- sudo -u ${TARGET_USER} sh ${GIT_WORK_TREE}deploy.sh
- fi
+ Edit /etc/rc.d/fcgiwrap to run as www user;
- # Done with project
- echo "Deploy: removing deploy file="$DP_FILE
- rm $DP_FILE
+
+ USER=nginx
+ GROUP=nginx
+
- exit 0;
- done
+
+ # usermod -G www,gitolite nginx
- Add cron job to call deploy script every minute;
+ Create link from gitweb to web server folder;
- # crontab -e
+ # ln -s /usr/share/gitweb /srv/www
+ Add this to default or main
+ nginx virtual host;
+
- #
- # /etc/crontab: crond(8) configuration
- #
+ location /gitweb/gitweb.cgi {
+ alias /srv/www/gitweb;
+ include fastcgi_params;
+ gzip off;
+ fastcgi_param SCRIPT_FILENAME /srv/www/gitweb/gitweb.cgi;
+ fastcgi_param GITWEB_CONFIG /etc/gitweb.conf;
+ fastcgi_pass unix:/var/run/fcgiwrap.sock;
+ }
- # this way it will log
- # * * * * * /usr/share/gitolite/deploy.sh
- # without log
- * * * * * /usr/share/gitolite/deploy.sh > /dev/null 2>&1
+ location /gitweb {
+ alias /srv/www/gitweb;
+ index gitweb.cgi;
+ }
+
- @hourly ID=sys.hourly /usr/sbin/runjobs /etc/cron/hourly
- @daily ID=sys.daily /usr/sbin/runjobs /etc/cron/daily
- @weekly ID=sys.weekly /usr/sbin/runjobs /etc/cron/weekly
- @monthly ID=sys.monthly /usr/sbin/runjobs /etc/cron/monthly
+ 5.3. Configure gitolite
- # End of file
+ Edit
+ /srv/gitolite/.gitolite.rc,
+ change UMASK and GIT_CONFIG_KEYS to;
+
+
+ # default umask gives you perms of '0700'; see the rc file docs for
+ # how/why you might change this
+ UMASK => 027,
+
+ # look for "git-config" in the documentation
+ GIT_CONFIG_KEYS => '.*',
+
+
+ Fix permissions;
+
+
+ $ sudo chown -R gitolite:gitolite /srv/gitolite
+ $ sudo chmod g+rx /srv/gitolite/projects.list
+ $ sudo chmod -R g+rx /srv/gitolite/repositories/
- 5. Gitweb
- Edit the /home/git/.gitolite.rc and change the UMASK value as 0027
+ Edit gitolite-admin/conf/gitolite.conf;
+
+
+ repo c9-doc
+ config gitweb.owner = c9 team
+ config gitweb.description = c9 documentation
+ config gitweb.category = c9
+
+ repo c9-ports
+ config gitweb.owner = c9 team
+ config gitweb.description = c9 ports
+ config gitweb.category = c9
+
+
Tools Index
This is part of the c9-doc Manual.
Copyright (C) 2016
--
cgit