git daemon init script and config
authorthierry <thierry@41d37cc5-eb28-0410-a9bf-d37491348ade>
Fri, 21 May 2010 13:27:14 +0000 (13:27 +0000)
committerthierry <thierry@41d37cc5-eb28-0410-a9bf-d37491348ade>
Fri, 21 May 2010 13:27:14 +0000 (13:27 +0000)
scripts/git-check.sh [new file with mode: 0755]
scripts/git-clone.sh [new file with mode: 0755]
scripts/git-daemon.init.d [new file with mode: 0755]
scripts/git-daemon.sysconfig [new file with mode: 0644]
scripts/gitweb-links.sh [new file with mode: 0755]

diff --git a/scripts/git-check.sh b/scripts/git-check.sh
new file mode 100755 (executable)
index 0000000..b87b3ea
--- /dev/null
@@ -0,0 +1,91 @@
+#!/bin/sh
+
+cd /git
+
+gitwebfiles="git-favicon.png git-logo.png gitweb.cgi gitweb.css"
+
+########
+gitwebpattern=""
+for file in $gitwebfiles; do gitwebpattern="${gitwebpattern}|$file" ; done
+gitwebpattern=$(echo "$gitwebpattern" | sed -e 's,|,,')
+
+### function count () {
+### 
+###     echo "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx counting"
+### 
+###     echo git
+###     ls git | wc -l 
+### 
+###     echo gitweb
+###     ls gitweb | egrep -v "$gitwebpattern" | wc -l 
+### 
+### }
+### 
+### function missing_in_git () {
+### 
+###     echo "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx missing in git"
+### 
+###     for i in $(ls gitweb | egrep -v $gitwebpattern); do 
+###    b=$(basename $i .git)
+###    [ -d git/$b ] || echo $b missing in git
+###     done
+### 
+### }
+
+function missing_in_gitweb () {
+
+###     echo "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx missing in gitweb (from git)"
+### 
+###     for i in $(ls git); do 
+###    echo -n "$i " 
+###    if [ ! -h gitweb/${i}.git ] ; then
+###        echo -n "ADDING $i.git "
+###        (cd git; ln -s ../$i/.git ${i}.git)
+###    fi
+###     done
+    
+    echo "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx missing in gitweb (for web)"
+    for i in $gitwebfiles; do
+       echo -n "$i "
+       if [ ! -h git/${i} ] ; then
+           echo "LINKING.. " ; (cd git; ln -s ../${i} .)
+       fi
+    done
+    echo ""
+
+}
+
+function fill_descriptions () {
+    echo "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx checking descriptions "
+    for arg in "$@" ; do
+       # accept args like git/plcapi
+       i=$(basename $arg)
+       echo -n "$i "
+       grep Unnamed git/$i/.git/description && { echo -n $i "Setting.. "; echo $i > git/$i/.git/description ; }
+    done
+    echo ""
+}
+
+function upload_archives () {
+    echo "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx checking configs for uploadarch "
+    for arg in "$@" ; do
+       # accept args like git/plcapi
+       i=$(basename $arg)
+       echo -n "$i "
+       if ! grep uploadarch git/$i/.git/config ; then
+           echo -n $i "Setting.. "; 
+           cat >> git/$i/.git/config <<EOF
+[daemon]
+       uploadpack = false
+       uploadarch = true
+EOF
+       fi
+    done
+    echo ""
+}
+
+#count
+#missing_in_git
+missing_in_gitweb
+fill_descriptions $(ls git | egrep -v "${gitwebpattern}")
+upload_archives $(ls git | egrep -v "${gitwebpattern}")
diff --git a/scripts/git-clone.sh b/scripts/git-clone.sh
new file mode 100755 (executable)
index 0000000..e6581fb
--- /dev/null
@@ -0,0 +1,37 @@
+#!/bin/bash
+
+# uses svn2git ruby script
+# install rubygems 
+# sudo gem install svn2git --source http://gemcutter.org
+
+#http provides really crappy performance....
+#SVNROOT="http://svn.planet-lab.org/svn"
+# so run locally at princeton
+SVNROOT="file:///svn"
+
+function clone () {
+    for arg in "$@" ; do
+       SVN_MODULE=$(basename $arg)
+       echo "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx converting module $SVN_MODULE in $(pwd)"
+       SVN_PATH=${SVNROOT}/${SVN_MODULE}
+       GIT_REPO=$(echo $SVN_MODULE | sed 's/.*/\L&/')
+
+#    rm -rf $TMPDIR
+#    mkdir -p $TMPDIR
+#    pushd $TMPDIR
+#    git svn init -s  $SVN_PATH --no-metadata
+#    git svn fetch
+#    popd
+
+       rm -rf $GIT_REPO
+       mkdir -p $GIT_REPO
+       pushd $GIT_REPO
+       svn2git $SVN_PATH
+       popd
+    done
+}
+
+args="$@"
+[[ -z "$args" ]] && args=$(ls /svn)
+
+clone $args
diff --git a/scripts/git-daemon.init.d b/scripts/git-daemon.init.d
new file mode 100755 (executable)
index 0000000..bc3e64b
--- /dev/null
@@ -0,0 +1,85 @@
+#!/bin/bash
+#
+# Init file for git daemon
+#
+# chkconfig: 2345 55 25
+# description: git server daemon
+#
+# processname: git-daemon
+# pidfile: /var/run/git.pid
+
+# source function library
+. /etc/rc.d/init.d/functions
+
+# pull in sysconfig settings
+[ -f /etc/sysconfig/git ] && . /etc/sysconfig/git
+
+RETVAL=0
+prog="git-daemon"
+
+# Some functions to make the below more readable
+GIT=/usr/bin/git-daemon
+PID_FILE=/var/run/git-daemon.pid
+
+# override OPTIONS altogether for more flexibility
+OPTIONS=${OPTIONS:- --pid-file=${PID_FILE} --base-path=${GITDIR} --port=${PORT} ${VERBOSE} ${DETACH} ${SYSLOG} ${EXPORT} ${GITWHITELIST}}
+
+runlevel=$(set -- $(runlevel); eval "echo \$$#" )
+
+start()
+{
+       echo -n $"Starting $prog: "
+       $GIT $OPTIONS && success || failure
+       RETVAL=$?
+       [ "$RETVAL" = 0 ] && touch /var/lock/subsys/git
+       echo
+}
+
+stop()
+{
+       echo -n $"Stopping $prog: "
+       if [ -n "`pidfileofproc $GIT`" ] ; then
+           killproc $GIT
+       else
+           failure $"Stopping $prog"
+       fi
+       RETVAL=$?
+       # if we are in halt or reboot runlevel kill all running sessions
+       # so the TCP connections are closed cleanly
+       if [ "x$runlevel" = x0 -o "x$runlevel" = x6 ] ; then
+           killall $prog 2>/dev/null
+       fi
+       [ "$RETVAL" = 0 ] && rm -f /var/lock/subsys/git
+       echo
+}
+
+case "$1" in
+       start)
+               start
+               ;;
+       stop)
+               stop
+               ;;
+       restart)
+               stop
+               start
+               ;;
+       condrestart)
+               if [ -f /var/lock/subsys/git ] ; then
+                       if [ "$RETVAL" = 0 ] ; then
+                               stop
+                               # avoid race
+                               sleep 3
+                               start
+                       fi
+               fi
+               ;;
+       status)
+               status -p $PID_FILE git-daemon
+               RETVAL=$?
+               ;;
+       *)
+               echo $"Usage: $0 {start|stop|restart|condrestart|status}"
+               RETVAL=1
+esac
+exit $RETVAL
diff --git a/scripts/git-daemon.sysconfig b/scripts/git-daemon.sysconfig
new file mode 100644 (file)
index 0000000..bfe5fae
--- /dev/null
@@ -0,0 +1,10 @@
+# variables looked at
+GITDIR=/git/git
+GITWHITELIST=/git/git/tests
+PORT=9418
+VERBOSE=
+DETACH=--detach
+SYSLOG=--syslog
+EXPORT=--export-all
+# or set this one in extenso
+# OPTIONS=
diff --git a/scripts/gitweb-links.sh b/scripts/gitweb-links.sh
new file mode 100755 (executable)
index 0000000..49fb1da
--- /dev/null
@@ -0,0 +1,15 @@
+#!/bin/bash
+
+GITDIR="git"
+GITWEBDIR="gitweb"
+
+function link () {
+    REPO=$(echo $1 | sed 's/.*/\L&/')
+    rm -f ${PWD}/${GITWEBDIR}/${REPO}.git
+    ln -s ${PWD}/${GITDIR}/${REPO}/.git/ ${PWD}/${GITWEBDIR}/${REPO}.git
+}
+
+for i in $*
+do
+  link $i
+done